使用xslt删除名称相似的根节点

时间:2016-09-06 07:45:40

标签: xml xslt xslt-1.0

我有像这样的xml

<?xml version="1.0" encoding="ASCII" standalone="yes"?>
<InvoiceTransmission xmlns="http://xxxxxxxxxxxxxxxx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.IATA.com/IATAAviationInvoiceStandard http://xxxxxxxxxxxxxxxx">
    <InvoiceTransmission>
        <TransmissionHeader>
            <TransmissionDateTime>xxxx</TransmissionDateTime>
            <Version>xxxx</Version>
            <TransmissionID>xxxxx</TransmissionID>
            <IssuingOrganizationID>xxx</IssuingOrganizationID>
            <BillingCategory>xx</BillingCategory>
        </TransmissionHeader>
        <Invoice>
            <InvoiceHeader>
                <InvoiceNumber>xxxx</InvoiceNumber>
                <InvoiceDate>xxx</InvoiceDate>
                <InvoiceType>xxxx</InvoiceType>
                <LocationCode>xxx</LocationCode>
                <ChargeCategory>xxxx</ChargeCategory>
                <SellerOrganization>
                    <OrganizationID>xxx</OrganizationID>
                    <OrganizationDesignator>xx</OrganizationDesignator>
                    <OrganizationName1>xxxx</OrganizationName1>
                    <ContactName>xxx</ContactName>
                    <Address>
                        <AddressLine1>xxx</AddressLine1>
                        <CityName>xxx</CityName>
                        <CountryCode>xxx</CountryCode>
                        <CountryName>xx</CountryName>
                        <PostalCode>xx</PostalCode>
                    </Address>
                </SellerOrganization>
    </InvoiceTransmission>
</InvoiceTransmission>

我试过使用xslt代码

<?xml version="1.0" encoding="ASCII" standalone="yes"?>
<InvoiceTransmission xmlns="http://xxxxxxxxxxxxxxxx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.IATA.com/IATAAviationInvoiceStandard http://xxxxxxxxxxxxxxxx">
    <TransmissionHeader>
        <TransmissionDateTime>xxxx</TransmissionDateTime>
        <Version>xxxx</Version>
        <TransmissionID>xxxxx</TransmissionID>
        <IssuingOrganizationID>xxx</IssuingOrganizationID>
        <BillingCategory>xx</BillingCategory>
    </TransmissionHeader>
    <Invoice>
        <InvoiceHeader>
            <InvoiceNumber>xxxx</InvoiceNumber>
            <InvoiceDate>xxx</InvoiceDate>
            <InvoiceType>xxxx</InvoiceType>
            <LocationCode>xxx</LocationCode>
            <ChargeCategory>xxxx</ChargeCategory>
            <SellerOrganization>
                <OrganizationID>xxx</OrganizationID>
                <OrganizationDesignator>xx</OrganizationDesignator>
                <OrganizationName1>xxxx</OrganizationName1>
                <ContactName>xxx</ContactName>
                <Address>
                    <AddressLine1>xxx</AddressLine1>
                    <CityName>xxx</CityName>
                    <CountryCode>xxx</CountryCode>
                    <CountryName>xx</CountryName>
                    <PostalCode>xx</PostalCode>
                </Address>
            </SellerOrganization>
</InvoiceTransmission>

但它没有给出正确的输出 但我希望我的输出像这样。

<?xml version="1.0" encoding="ASCII" standalone="yes"?>
<InvoiceTransmission xmlns="http://xxxxxxxxxxxxxxxx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.IATA.com/IATAAviationInvoiceStandard http://xxxxxxxxxxxxxxxx">
    <TransmissionHeader>
        <TransmissionDateTime>xxxx</TransmissionDateTime>
        <Version>xxxx</Version>
        <TransmissionID>xxxxx</TransmissionID>
        <IssuingOrganizationID>xxx</IssuingOrganizationID>
        <BillingCategory>xx</BillingCategory>
    </TransmissionHeader>
    <Invoice>
        <InvoiceHeader>
            <InvoiceNumber>xxxx</InvoiceNumber>
            <InvoiceDate>xxx</InvoiceDate>
            <InvoiceType>xxxx</InvoiceType>
            <LocationCode>xxx</LocationCode>
            <ChargeCategory>xxxx</ChargeCategory>
            <SellerOrganization>
                <OrganizationID>xxx</OrganizationID>
                <OrganizationDesignator>xx</OrganizationDesignator>
                <OrganizationName1>xxxx</OrganizationName1>
                <ContactName>xxx</ContactName>
                <Address>
                    <AddressLine1>xxx</AddressLine1>
                    <CityName>xxx</CityName>
                    <CountryCode>xxx</CountryCode>
                    <CountryName>xx</CountryName>
                    <PostalCode>xx</PostalCode>
                </Address>
            </SellerOrganization>
</InvoiceTransmission>

这&#34; InvoiceTransmission&#34;节点重复两次  我想第二次删除

0 个答案:

没有答案