Subject: [xsl] Selecting the value from diff i/p XML From: Shashank Jain <shashankjain@xxxxxxxx> Date: Wed, 15 Sep 2010 16:21:50 -0500 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Are there any XSLT proces, Dimitre Novatchev | Thread | Re: [xsl] Selecting the value from , Imsieke, Gerrit, le- |
Re: [xsl] Matching a local scope na, Wendell Piez | Date | Re: [xsl] Selecting the value from , Imsieke, Gerrit, le- |
Month |