eclipse - xsl 输出 eclipse 中的额外命名空间
问题描述
由于我们公司正在从 AX 转移到 SAP,我也在从 Visual Studio 到 Eclipse 进行“转变”。我认为从一个小的 xslt 项目开始会很好,但是在尝试我现有的(用 VS 制作的)xsl 时,我注意到了一些差异。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="msxsl:SalesType">
<xsl:choose>
<xsl:when test="(../msxsl:SalesType) = 'ReturnItem'">
<xsl:element name="MessageType" namespace="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">384</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="MessageType" namespace="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
生成带有 msxsl 前缀 xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380 的输出 xml:
<?xml version="1.0" encoding="UTF-8"?>
<Envelope
xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header>
<MessageId>{0E415D3C-6D46-4E4E-B8CA-9729B11BA}</MessageId>
<SourceEndpoint>BAB</SourceEndpoint>
<DestinationEndpoint>INVOIC_WKMP</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/read
</Action>
</Header>
<Body>
<MessageParts>
<SalesInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<CustInvoiceJour class="entity">
<AccountcategoryId>FFF</AccountcategoryId>
<msxsl:MessageType
xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380</msxsl:MessageType>
</CustInvoiceJour>
</SalesInvoice>
</MessageParts>
</Body>
</Envelope>
而 Visual Studio xsl 省略了 xmlns:msxsl 规范(这是正确的):
<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header>
<MessageId>{0E415D3C-6D46-4E4E-B8CA-9729B11BA}</MessageId>
<SourceEndpoint>BAB</SourceEndpoint>
<DestinationEndpoint>INVOIC_WKMP</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/read</Action>
</Header>
<Body>
<MessageParts>
<SalesInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<CustInvoiceJour class="entity">
<AccountcategoryId>FFF</AccountcategoryId>
<MessageType>380</MessageType>
</CustInvoiceJour>
</SalesInvoice>
</MessageParts>
</Body>
</Envelope>
由于它已经在http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice命名空间中,因此我不想在此处添加此内容。我有什么办法可以在 Eclipse 中改变这一点?
亲切的问候,
麦克风
解决方案
不,Visual Studio 省略此命名空间是不正确的。如果您不想包含它,则应使用xsl:exclude-result-prefixes="msxsl"
.
推荐阅读
- javascript - 如何使用 JavaScript 强制 CSS 使用/显示 hsl 值而不是 RGB?
- c - C语言如何从返回值函数返回错误
- python - MultiIndex 列 DataFrame 的成对差异
- c# - 将 Razor 视图转换为字符串 ASP.NET 核心
- python - wxPython小部件的像素完美对齐?
- javascript - 到目前为止,进度条和总数未显示
- java - 当数据库表没有记录时,停止 ResultSet 触发弹出窗口
- delphi - Delphi 数组:变量 Myvar 可能未初始化
- c++ - 查找给定字符串中括号对的序号
- angular - 角度嵌套路由未调用组件