2017-01-11 10 views
1

封筒を削除する必要があります:StandardBusinessDocument、sh:StandardBusinessDocumentHeaderおよびObjectEnvelopeは請求書をそのまま残します。XSLTを使用してXMLエンベロープを削除する必要があります

<?xml version="1.0" encoding="ISO-8859-1"?> 
<Invoice xmlns="urn:sfti:documents:BasicInvoice:1:0" xmlns:cac="urn:sfti:CommonAggregateComponents:1:0" xmlns:cbc="urn:oasis:names:tc:ubl:CommonBasicComponents:1:0" xmlns:ccts="urn:oasis:names:tc:ubl:CoreComponentParameters:1:0" xmlns:cur="urn:oasis:names:tc:ubl:codelist:CurrencyCode:1:0" xmlns:sdt="urn:oasis:names:tc:ubl:SpecializedDatatypes:1:0" xmlns:udt="urn:oasis:names:tc:ubl:UnspecializedDatatypes:1:0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <ID>2522987548</ID> 
    <cbc:IssueDate>2017-01-01</cbc:IssueDate> 
    <InvoiceTypeCode>380</InvoiceTypeCode> 
    <cbc:Note>Vid frågor gällande resedebiteringar, kontakta din lokala resebyrå. Övrigt, kontakta Kundservice.</cbc:Note> 
    <InvoiceCurrencyCode>SEK</InvoiceCurrencyCode> 
    <LineItemCountNumeric>4</LineItemCountNumeric> 
    <AdditionalDocumentReference> 
    <cac:ID identificationSchemeID="CT">197911</cac:ID> 
    </AdditionalDocumentReference> 
    <AdditionalDocumentReference> 
    <cac:ID identificationSchemeID="ACD">197911</cac:ID> 
    </AdditionalDocumentReference> 
    <cac:BuyerParty> 
    <cac:Party> 
     <cac:PartyIdentification> 
     <cac:ID identificationSchemeID="92">5560452103</cac:ID> 
     </cac:PartyIdentification> 
     <cac:PartyName> 
     <TwoHundreedMoreFields>...</TwoHundreedMoreFields> 
     </cac:PartyName> 
    </cac:Party> 
    </cac:BuyerParty> 
    <cac:SellerParty> 
    <cac:Party> 
     <cac:PartyIdentification> 
     <cac:ID identificationSchemeID="91">5164060120</cac:ID> 
     </cac:PartyIdentification> 
     <cac:PartyName> 
     <TwoHundreedMoreFields>...</TwoHundreedMoreFields> 
     </cac:PartyName> 
    </cac:Party> 
    </cac:SellerParty> 
    <cac:InvoiceLine> 
    <cac:ID>31</cac:ID> 
    <cbc:InvoicedQuantity quantityUnitCode="">1.00</cbc:InvoicedQuantity> 
    <cbc:LineExtensionAmount amountCurrencyID="SEK">340.00</cbc:LineExtensionAmount> 
    <cbc:Note>ARLANDA PARKERING STHLM ARLANDA Netto: 340,00 Moms: 0,00 Brutto: 340,00</cbc:Note> 
    </cac:InvoiceLine> 
    <cac:InvoiceLine> 
    <cac:ID>32</cac:ID> 
    <cbc:InvoicedQuantity quantityUnitCode="">1.00</cbc:InvoicedQuantity> 
    <cbc:LineExtensionAmount amountCurrencyID="SEK">2273.00</cbc:LineExtensionAmount> 
    <cbc:Note>Something AB Bromma Netto: 2273,00 Moms: 0,00 Brutto: 2273,00</cbc:Note> 
    </cac:InvoiceLine> 
</Invoice> 

私は私が必要な部分を切り出し、XSLTといくつかの異なる方法を試してみましたが、どれも完全には働いていないこと:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<sh:StandardBusinessDocument xmlns:sh="urn:sfti:documents:StandardBusinessDocumentHeader" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<sh:StandardBusinessDocumentHeader> 
<sh:HeaderVersion>1.0</sh:HeaderVersion> 
<sh:Sender> 
<sh:Identifier Authority="countrycode:organizationid">3465560211475</sh:Identifier> 
</sh:Sender> 
<sh:Receiver> 
<sh:Identifier Authority="countrycode:organizationid">5620452103</sh:Identifier> 
</sh:Receiver> 
<sh:DocumentIdentification> 
<sh:Standard>urn:sfti:documents:BasicInvoice:1:0</sh:Standard> 
<sh:TypeVersion>1.0</sh:TypeVersion> 
<sh:InstanceIdentifier>0511323816</sh:InstanceIdentifier> 
<sh:Type>BasicInvoice</sh:Type> 
<sh:MultipleType>true</sh:MultipleType> 
<sh:CreationDateAndTime>2017-01-04T05:48:14</sh:CreationDateAndTime> 
</sh:DocumentIdentification> 
</sh:StandardBusinessDocumentHeader> 
<Invoice xmlns="urn:sfti:documents:BasicInvoice:1:0" xmlns:cac="urn:sfti:CommonAggregateComponents:1:0" xmlns:cbc="urn:oasis:names:tc:ubl:CommonBasicComponents:1:0" xmlns:ccts="urn:oasis:names:tc:ubl:CoreComponentParameters:1:0" xmlns:cur="urn:oasis:names:tc:ubl:codelist:CurrencyCode:1:0" xmlns:sdt="urn:oasis:names:tc:ubl:SpecializedDatatypes:1:0" xmlns:udt="urn:oasis:names:tc:ubl:UnspecializedDatatypes:1:0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <ID>2522987548</ID> 
    <cbc:IssueDate>2017-01-01</cbc:IssueDate> 
    <InvoiceTypeCode>380</InvoiceTypeCode> 
    <cbc:Note>Vid frågor gällande resedebiteringar, kontakta din lokala resebyrå. Övrigt, kontakta Kundservice.</cbc:Note> 
    <InvoiceCurrencyCode>SEK</InvoiceCurrencyCode> 
    <LineItemCountNumeric>4</LineItemCountNumeric> 
    <AdditionalDocumentReference> 
    <cac:ID identificationSchemeID="CT">197911</cac:ID> 
    </AdditionalDocumentReference> 
    <AdditionalDocumentReference> 
    <cac:ID identificationSchemeID="ACD">197911</cac:ID> 
    </AdditionalDocumentReference> 
    <cac:BuyerParty> 
    <cac:Party> 
     <cac:PartyIdentification> 
     <cac:ID identificationSchemeID="92">5560452103</cac:ID> 
     </cac:PartyIdentification> 
     <cac:PartyName> 
     <TwoHundreedMoreFields>...</TwoHundreedMoreFields> 
     </cac:PartyName> 
    </cac:Party> 
    </cac:BuyerParty> 
    <cac:SellerParty> 
    <cac:Party> 
     <cac:PartyIdentification> 
     <cac:ID identificationSchemeID="91">5164060120</cac:ID> 
     </cac:PartyIdentification> 
     <cac:PartyName> 
     <TwoHundreedMoreFields>...</TwoHundreedMoreFields> 
     </cac:PartyName> 
    </cac:Party> 
    </cac:SellerParty> 
    <cac:InvoiceLine> 
    <cac:ID>31</cac:ID> 
    <cbc:InvoicedQuantity quantityUnitCode="">1.00</cbc:InvoicedQuantity> 
    <cbc:LineExtensionAmount amountCurrencyID="SEK">340.00</cbc:LineExtensionAmount> 
    <cbc:Note>ARLANDA PARKERING STHLM ARLANDA Netto: 340,00 Moms: 0,00 Brutto: 340,00</cbc:Note> 
    </cac:InvoiceLine> 
    <cac:InvoiceLine> 
    <cac:ID>32</cac:ID> 
    <cbc:InvoicedQuantity quantityUnitCode="">1.00</cbc:InvoicedQuantity> 
    <cbc:LineExtensionAmount amountCurrencyID="SEK">2273.00</cbc:LineExtensionAmount> 
    <cbc:Note>Something AB Bromma Netto: 2273,00 Moms: 0,00 Brutto: 2273,00</cbc:Note> 
    </cac:InvoiceLine> 
</Invoice> 
<ObjectEnvelope xmlns:cac="urn:sfti:CommonAggregateComponents:1:0" xmlns:cbc="urn:oasis:names:tc:ubl:CommonBasicComponents:1:0" xmlns:cct="urn:oasis:names:tc:ubl:CoreComponentTypes:1:0" xmlns:udt="urn:oasis:names:tc:ubl:UnspecializedDatatypes:1:0" xmlns="urn:sfti:documents:ObjectEnvelope:1:0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<DocumentReference> 
<DocumentID>2522987548</DocumentID> 
<IssueDate>2017-01-04</IssueDate> 
<IssuerID>CGI</IssuerID> 
<DocumentType>urn:sfti:documents:BasicInvoice:1:0</DocumentType> 
</DocumentReference> 
<CreationDateTime>2017-01-04T05:48:14</CreationDateTime> 
</ObjectEnvelope> 
</sh:StandardBusinessDocument> 

は、私はそれが次のようになりたいです。

例:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sh="urn:sfti:documents:StandardBusinessDocumentHeader" xmlns:cac="urn:sfti:CommonAggregateComponents:1:0" version="1.0"> 

<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="Invoice"> 
    <xsl:apply-templates/> 
    </xsl:template> 
<xsl:template match="sh:StandardBusinessDocumentHeader"/> 
<xsl:template match="ObjectEnvelope"/> 
</xsl:stylesheet> 

または:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sh="urn:sfti:documents:StandardBusinessDocumentHeader" version="1.0"> 
    <xsl:output method="xml" indent="yes"/> 
    <xsl:strip-space elements="*"/> 
    <xsl:template match="/"> 
    <Invoice xmlns="urn:sfti:documents:BasicInvoice:1:0" > 
    <xsl:copy-of select="/sh:StandardBusinessDocument/*"/> 
    </Invoice> 
</xsl:template> 
<xsl:template match="sh:StandardBusinessDocumentHeader"/> 
<xsl:template match="ObjectEnvelope"/> 
</xsl:stylesheet> 

助けてください。

私はhttp://www.utilities-online.info/xsltransformation/#.WHX9klPhD-jを使用してコードを確認しています。素晴らしい小さなページ。

よろしく、 Svante

+1

http://xsltransform.net/サービスであること、利用可能なときに(より良いユーティリティです。 ...) –

答えて

1

試してみてください。

XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:inv="urn:sfti:documents:BasicInvoice:1:0"> 
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
<xsl:strip-space elements="*"/> 

<xsl:template match="/"> 
    <xsl:copy-of select="/*/inv:Invoice"/> 
</xsl:template> 

</xsl:stylesheet> 
+0

ありがとうマイケル! :) – Svante

+0

@Svanteあなたの質問に答えられたら、答えを受け入れて閉じてください。 –

関連する問題