One.xml獲取兩個XML的
<?xml version='1.0' encoding='ISO-8859-1'?>
<todo-lists type='array'>
<todo-list>
<id type='integer'>10663712</id>
<name>Pyramid</name>
<todo-items type='array'>
<todo-item>
<id type='integer'>67431502</id>
<content>General Items that you are working on. Enter brief description
on what you worked on.</content>
</todo-item>
<todo-item>
<id type='integer'>78230534</id>
<content>Schedule FTPExport checking on Production.</content>
</todo-item>
<todo-item>
<id type='integer'>78230579</id>
<content>Adding Smartphone and MobileHandsets Sector on DEV</content>
</todo-item>
<todo-item>
<id type='integer'>78610242</id>
<content>Adding new Sectors on DEV.</content>
</todo-item>
</todo-items>
<todo-list>
</todo-lists>
two.xml的XSLT
<time-entries>
<time-entry>
<date type="date">2011-02-28</date>
<description>Learn Ajax,Webservices,JSON in Javascript</description>
<hours type="float">8.0</hours>
<id type="integer">35458966</id>
<person-id type="integer">6557642</person-id>
<email-address>[email protected]</email-address>
<project-id type="integer">1802011</project-id>
<todo-item-id type="integer">67431502</todo-item-id>
</time-entry>
<time-entry>
<date type="date">2011-02-28</date>
<description>for testing purposes... Ranjeet</description>
<hours type="float">1.25</hours>
<id type="integer">35380151</id>
<person-id type="integer">5949975</person-id>
<email-address>[email protected]</email-address>
<project-id type="integer">1802011</project-id>
<todo-item-id type="integer" nil="true"/>
</time-entry>
<time-entry>
<date type="date">2011-02-28</date>
<description>For Testing purposes....Ranjeet</description>
<hours type="float">1.01667</hours>
<id type="integer">35380081</id>
<person-id type="integer">5949975</person-id>
<email-address>[email protected]</email-address>
<project-id type="integer">1802011</project-id>
<todo-item-id type="integer" nil="true">78230534</todo-item-id>
</time-entry>
</time-entries>
answer.xml
<?xml version='1.0' encoding='ISO-8859-1'?>
<todo-lists type='array'>
<todo-list>
<id type='integer'>10663712</id>
<name>Pyramid</name>
<todo-items type='array'>
<todo-item>
<id type='integer'>67431502</id>
<content>General Items that you are working on. Enter brief description
on what you worked on.</content>
<description>Learn Ajax,Webservices,JSON in Javascript</description>
</todo-item>
<todo-item>
<id type='integer'>78230534</id>
<content>Schedule FTPExport checking on Production.</content>
<description>For Testing purposes....Ranjeet</description>
</todo-item>
<todo-item>
<id type='integer'>78230579</id>
<content>Adding Smartphone and MobileHandsets Sector on DEV</content>
</todo-item>
<todo-item>
<id type='integer'>78610242</id>
<content>Adding new Sectors on DEV.</content>
</todo-item>
</todo-items>
<todo-list>
</todo-lists>
使用XSLT從使用請拿到answer.xml one.xml和two.xml中存在匹配一個元素的ie文件one.xml中有<id type='integer'>67431502</id>
,這兩個文件與two.xml的<todo-item-id type="integer">67431502</todo-item-id>
相匹配以獲得a nswer.xml
好問題,+1。查看我的答案,獲得基於最基本的XSLT設計模式的完整,簡短且容易的XSLT解決方案 - 使用和覆蓋身份規則。還提供了廣泛的解釋。 – 2011-03-18 13:01:58