0
如果這篇文章寫得不好,但是這是我第一次接觸XSLT。XSL轉換 - 排除某些兒童
以下是xml結構示例。
<ProcessedOrder>
<ProcessDetail>
<Detail1>Some Sample Data</Detail1>
</ProcessDetail>
<Management>
<Employee Id="EM156896">
<Name>James Davies</Name>
</Employee>
</Management>
<Order Id="IR1245486">
<Details>
<Date>01-02-2011</Date>
<Name>XSLT : The Complete Beginners Guide</Name>
<Description>The Complete Beginners Guide to XSL Transformations</Description>
</Details>
<Delivery>
<Customer Id="CN005687">
<Name>John Henry</Name>
<ContactInformation>
<AddressLine1>55 John Street</AddressLine1>
<Country _Id="GBR">United Kingdom</Country>
<Phone>1234-123456</Phone>
<Fax>1234-5544-2250</Fax>
<EmailAddress>[email protected]</EmailAddress>
<City>London</City>
<PostalCode>AW7T 3XS</PostalCode>
</ContactInformation>
</Customer>
</Delivery>
</Order>
<Billing>
<Customer Id="CN005858">
<Name>Thomas Henry</Name>
<ContactInformation>
<AddressLine1>66 Thomas Street</AddressLine1>
<Country _Id="GBR">United Kingdom</Country>
<Phone>1234-545464</Phone>
<Fax>2233-8989-1234</Fax>
<EmailAddress>[email protected]</EmailAddress>
<City>Bristol</City>
<PostalCode>BS4Y 2WT</PostalCode>
</ContactInformation>
</Customer>
</Billing>
</ProcessedOrder>
//所需的輸出
<Order Id="IR1245486">
<Details>
<Date>01-02-2011</Date>
<Name>XSLT : The Complete Beginners Guide</Name>
<Description>The Complete Beginners Guide to XSL Transformations</Description>
</Details>
<Delivery>
<Customer Id="CN005858">
<Name>Thomas Henry</Name>
<ContactInformation>
<AddressLine1>66 Thomas Street</AddressLine1>
<Country _Id="GBR">United Kingdom</Country>
<Phone>1234-545464</Phone>
<Fax>2233-8989-1234</Fax>
<EmailAddress>[email protected]</EmailAddress>
<City>Bristol</City>
<PostalCode>BS4Y 2WT</PostalCode>
</ContactInformation>
</Customer>
</Delivery>
</Order>
我試圖轉型過程中做了一些事情。
- 從XML
- 提取
<Order>
從<Billing>
其中<Delivery><Customer>
是排除來自<Delivery>
- 插入
<Customer>
的<Customer>
。
我假設我可以使用下面的提取訂單..
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="//Order"/>
</xsl:template>
<xsl:template match="Order">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
一旦我開始試圖排除客戶我完全迷路..
任何幫助將是不勝感激。
非常感謝,
M.
馬丁,萬分感謝了回來我在這。我將貫穿您提出的解決方案。乍一看,它似乎比我試圖實施自己的解決方案的一些更合乎邏輯。 – user617850 2011-02-15 16:15:23