获取两个xml的xslt';s
One.xml获取两个xml的xslt';s,xslt,Xslt,One.xml 10663712 金字塔 67431502 您正在处理的常规项目。输入简要描述 关于你的工作。 78230534 安排FTP出口检查生产。 78230579 在DEV上添加智能手机和移动手持设备扇区 78610242 在DEV.com上添加新的扇区。 two.xml <?xml version='1.0' encoding='ISO-8859-1'?> <todo-lists type='array'> <todo-list>
10663712
金字塔
67431502
您正在处理的常规项目。输入简要描述
关于你的工作。
78230534
安排FTP出口检查生产。
78230579
在DEV上添加智能手机和移动手持设备扇区
78610242
在DEV.com上添加新的扇区。
two.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>
2011-02-28
学习Javascript中的Ajax、Web服务和JSON
8
35458966
6557642
akumar@tekege.com
1802011
67431502
2011-02-28
为了测试的目的。。。兰吉特
1.25
35380151
5949975
rkumar@tekege.com
1802011
2011-02-28
出于测试目的…兰吉特
1.01667
35380081
5949975
rkumar@tekege.com
1802011
78230534
answer.xml
<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>akumar@tekege.com</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>rkumar@tekege.com</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>rkumar@tekege.com</email-address>
<project-id type="integer">1802011</project-id>
<todo-item-id type="integer" nil="true">78230534</todo-item-id>
</time-entry>
</time-entries>
10663712
金字塔
67431502
您正在处理的常规项目。输入简要描述
关于你的工作。
学习Javascript中的Ajax、Web服务和JSON
78230534
安排FTP出口检查生产。
出于测试目的…兰吉特
78230579
在DEV上添加智能手机和移动手持设备扇区
78610242
在DEV.com上添加新的扇区。
请使用xslt从using one.xml和two.xml中获取answer.xml,其中一个元素与ie one.xml中的
67431502
匹配,该元素与two.xml的67431502
匹配,以获取答案。xml此转换:
<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>akumar@tekege.com</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>rkumar@tekege.com</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>rkumar@tekege.com</email-address>
<project-id type="integer">1802011</project-id>
<todo-item-id type="integer" nil="true">78230534</todo-item-id>
</time-entry>
</time-entries>
<?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>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my" >
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<my:doc2>
<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>akumar@tekege.com</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>rkumar@tekege.com</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>rkumar@tekege.com</email-address>
<project-id type="integer">1802011</project-id>
<todo-item-id type="integer" nil="true">78230534</todo-item-id>
</time-entry>
</time-entries>
</my:doc2>
<xsl:variable name="vDoc2" select="document('')/*/my:doc2"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="todo-item[id = document('')/*/my:doc2/*/*/id]">
<xsl:copy>
<xsl:apply-templates select=
"node()|@*|$vDoc2/*/*[id = current()/id]/description"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
2011-02-28
学习Javascript中的Ajax、Web服务和JSON
8
35458966
6557642
akumar@tekege.com
1802011
67431502
2011-02-28
为了测试的目的。。。兰吉特
1.25
35380151
5949975
rkumar@tekege.com
1802011
2011-02-28
出于测试目的…兰吉特
1.01667
35380081
5949975
rkumar@tekege.com
1802011
78230534
应用于提供的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>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my" >
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<my:doc2>
<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>akumar@tekege.com</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>rkumar@tekege.com</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>rkumar@tekege.com</email-address>
<project-id type="integer">1802011</project-id>
<todo-item-id type="integer" nil="true">78230534</todo-item-id>
</time-entry>
</time-entries>
</my:doc2>
<xsl:variable name="vDoc2" select="document('')/*/my:doc2"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="todo-item[id = document('')/*/my:doc2/*/*/id]">
<xsl:copy>
<xsl:apply-templates select=
"node()|@*|$vDoc2/*/*[id = current()/id]/description"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
10663712
金字塔
67431502
您正在处理的常规项目。输入简要描述
关于你的工作。
78230534
安排FTP出口检查生产。
78230579
在DEV上添加智能手机和移动手持设备扇区
78610242
在DEV.com上添加新的扇区。
生成所需的正确答案:
<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>
10663712
金字塔
67431502
您正在处理的常规项目。输入简要描述
关于你的工作。
78230534
安排FTP出口检查生产。
78230579
在DEV上添加智能手机和移动手持设备扇区
78610242
在DEV.com上添加新的扇区。
说明:
<?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>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my" >
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<my:doc2>
<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>akumar@tekege.com</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>rkumar@tekege.com</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>rkumar@tekege.com</email-address>
<project-id type="integer">1802011</project-id>
<todo-item-id type="integer" nil="true">78230534</todo-item-id>
</time-entry>
</time-entries>
</my:doc2>
<xsl:variable name="vDoc2" select="document('')/*/my:doc2"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="todo-item[id = document('')/*/my:doc2/*/*/id]">
<xsl:copy>
<xsl:apply-templates select=
"node()|@*|$vDoc2/*/*[id = current()/id]/description"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
document()
函数调用的参数被替换为特定的文件URLtodo项
元素,这些元素的id
子元素的值与第二个文档中某个时间条目
元素的id
子元素的值相同时间条目的描述
子元素
对于键,此样式表:
<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>
输出:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="kDescriptionById"
match="description"
use="../todo-item-id"/>
<xsl:variable name="vSource2" select="document('two.xml')"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="todo-item">
<xsl:variable name="vCurrent" select="."/>
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:for-each select="$vSource2">
<xsl:apply-templates
select="key('kDescriptionById',$vCurrent/id)"/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
10663712
金字塔
67431502
您正在处理的常规项目。输入您所从事工作的简要说明。
学习Javascript中的Ajax、Web服务和JSON
78230534
安排FTP出口检查生产。
出于测试目的…兰吉特
78230579
在DEV上添加智能手机和移动手持设备扇区
78610242
在DEV.com上添加新的扇区。
注意:键()<