复制所有没有前缀的xml节点

时间:2016-08-01 12:49:38

标签: xml prefix

我需要复制一个包含前缀而不带前缀的完整xml 我尝试了一些使用exclude-result-prefixes但没有成功的解决方案

我使用了下面的xslt

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
    xmlns:ns0="http://www.openapplications.org/oagis/9" xmlns:ns2="http://www.openapplications.org/oagis/9/currencycode/54217:2001" xmlns:ns7="http://www.openapplications.org/oagis/9/codelists" xmlns:ns1="http://www.openapplications.org/oagis/9/qualifieddatatypes/1.1" xmlns:ns3="http://www.openapplications.org/oagis/9/languagecode/5639:1988" xmlns:ns4="http://www.openapplications.org/oagis/9/unitcode/66411:2001" xmlns:ns6="http://www.openapplications.org/oagis/9/IANAMIMEMediaTypes:2003" xmlns:ns5="http://www.openapplications.org/oagis/9/unqualifieddatatypes/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    exclude-result-prefixes="ns0">

    <xsl:template match="*" mode="copy">
      <xsl:element name="{name()}" namespace="{namespace-uri()}">
        <xsl:apply-templates select="@*|node()" mode="copy" />
      </xsl:element>
    </xsl:template>

    <xsl:template match="@*|text()|comment()" mode="copy">
      <xsl:copy/>
    </xsl:template>

    </xsl:stylesheet>

这是源

    <?xml version="1.0" encoding="utf-8"?>
    <ns0:AcknowledgePurchaseOrder releaseID="" systemEnvironmentCode="Production" languageCode="en-US" xmlns:ns0="http://www.openapplications.org/oagis/9" xmlns:ns2="http://www.openapplications.org/oagis/9/currencycode/54217:2001" xmlns:ns7="http://www.openapplications.org/oagis/9/codelists" xmlns:ns1="http://www.openapplications.org/oagis/9/qualifieddatatypes/1.1" xmlns:ns3="http://www.openapplications.org/oagis/9/languagecode/5639:1988" xmlns:ns4="http://www.openapplications.org/oagis/9/unitcode/66411:2001" xmlns:ns6="http://www.openapplications.org/oagis/9/IANAMIMEMediaTypes:2003" xmlns:ns5="http://www.openapplications.org/oagis/9/unqualifieddatatypes/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ns0:ApplicationArea>
    <ns0:Sender>
                     <ns0:LogicalID>SEC</ns0:LogicalID>
            </ns0:Sender>
            <ns0:CreationDateTime>2016-06-15</ns0:CreationDateTime>
    </ns0:ApplicationArea>
    <ns0:DataArea>
            <ns0:Acknowledge>
                     <ns0:ResponseCriteria>
                             <ns0:ResponseExpression actionCode="update"/>
                     </ns0:ResponseCriteria>
            </ns0:Acknowledge>
            <ns0:PurchaseOrder>
                     <ns0:PurchaseOrderHeader>
                             <ns0:DocumentID xsi:type="ns0:ItemIDType">
                                      <ns0:ID>6286952</ns0:ID>
                             </ns0:DocumentID>
                             <ns0:Attachment inline="false"/>
                             <ns0:CustomerParty>
                                      <ns0:PartyIDs>
                                              <ns0:ID>692627</ns0:ID>
                                      </ns0:PartyIDs>
                             </ns0:CustomerParty>
                             <ns0:SupplierParty>
                                      <ns0:PartyIDs>
                                              <ns0:ID>SEC</ns0:ID>
                                      </ns0:PartyIDs>
                             </ns0:SupplierParty>
                     </ns0:PurchaseOrderHeader>
                     <ns0:PurchaseOrderLine>
                             <ns0:LineNumber>1</ns0:LineNumber>
                             <ns0:DocumentReference type="PurchaseOrder">
                                      <ns0:DocumentID xsi:type="ns0:ItemIDType">
                                              <ns0:ID>310924</ns0:ID>
                                      </ns0:DocumentID>
                             </ns0:DocumentReference>
                             <ns0:Attachment inline="false"/>
                             <ns0:Item>
                                      <ns0:CustomerItemID>
                                              <ns0:ID>02898347</ns0:ID>
                                      </ns0:CustomerItemID>
                             </ns0:Item>
                             <ns0:Quantity>30</ns0:Quantity>
                             <ns0:UnitPrice>
                                      <ns0:Amount currencyID="SEK">522.03</ns0:Amount>
                                      <ns0:PerQuantity>1</ns0:PerQuantity>
                             </ns0:UnitPrice>
                             <ns0:DrawingAttachment xsi:type="ns0:OpenAttachmentType" inline="false"/>
                             <ns0:PromisedDeliveryDateTime>2016-08-01</ns0:PromisedDeliveryDateTime>
                             <ns0:PurchaseOrderSubLine>
                                      <ns0:Attachment inline="false"/>
                             </ns0:PurchaseOrderSubLine>
                             <ns0:PurchaseOrderSchedule>
                                      <ns0:Attachment inline="false"/>
                             </ns0:PurchaseOrderSchedule>
                     </ns0:PurchaseOrderLine>
            </ns0:PurchaseOrder>
    </ns0:DataArea>
    </ns0:AcknowledgePurchaseOrder>

我将从所有节点中删除所有ns0:

0 个答案:

没有答案