简体   繁体   English

XSL输出中的额外名称空间

[英]Extra namespace in xsl output eclipse

Since our company is moving from AX to SAP I'm also making a 'shift' from visual studio to eclipse. 由于我们公司已经从AX迁移到SAP,因此我也正在从Visual Studio转向日食。 I'd thought it would be nice to start with a small xslt project but when trying my existing (made in VS) xsl I noticed some differences. 我以为从一个小的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>

Generates an output xml with msxsl prefix xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380: 生成带有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>

Whereas visual studio xsl leaves out the xmlns:msxsl specification (which is correct): 而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>

Since it's already in the http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice namespace I don't want this addition here. 由于它已经在http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice命名空间中,因此我不想在这里添加。 Is there anything I can do to change this in eclipse? 我可以做些什么来改变日食吗?

Kind regards, 亲切的问候,

Mike 麦克风

No, Visual Studio is NOT correct to omit this namespace. 不可以,Visual Studio不正确地忽略此命名空间。 If you don't want it included you should explicitly omit it using xsl:exclude-result-prefixes="msxsl" . 如果您不希望包含它,则应使用xsl:exclude-result-prefixes="msxsl"明确省略它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM