Hello All,
I have two XML docs
Root1.xml and Root2.xml
==============================
Root1.xml looks like this
<root1>
<item id="1" value="A"/>
<item id="21" value="B"/>
<item id="3" value="C"/>
<item id="45" value="D"/>
<item id="5" value="E"/>
<item id="6" value="F"/>
<item id="78" value="G"/>
<item id="8" value="H"/>
<item id="9" value="I"/>
<item id="10" value="J"/>
</root1>
==================================
Root2.XML looks like this
<root2>
<data id="1"/>
<data id="2"/>
<data id="3"/>
<data id="4"/>
<data id="5"/>
<data id="6"/>
<data id="7"/>
<data id="8"/>
<data id="9"/>
<data id="10"/>
<data id="11"/>
<data id="2"/>
</root2>
===================================
I want the compare the @id of both the <item> and <data> and when it matches I
want the value of the @value.
so for in this case my output would be
A
C
E
F
H
I
J
========================================
I wrote this XSLT
<xsl:key name="idlist" match="root2/data" use="@id"/>
<xsl:variable name="data" select="document('Root1.xml')"/>
<xsl:template match="/">
<xsl:for-each select="key('idlist', $data/root1/item/@id)">
<xsl:value-of select="@id"/>
<br/>
</xsl:for-each>
</xsl:template>
and
I am getting this output
1
3
5
6
8
9
10
By applying this XSLT on Root2.xml I am able to print the @id of <data>
element. But how to get the @value of <item> element from Root1.xml.
I always want to apply my XSLT on Root2.xml
Thanks,
Shashank jain
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--