[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hello List,
I have a problem, I am not able to access any nodes/values from a Loop.
I have a sorted result tree fragment in a variable, I am using msxsl node-set to loop through it.
Now when I need to access the other nodes of the document I am not able to do so.
Pl. see below for the partial xsl and xml code. I have put two comments in the xsl file one where I need the external node values but not able to retrieve and second where I am able to retreive but do not need
How can I access the outer/external nodes inside the loop, I also tried using key() but it also didn't work inside the loop. It was working fine outside the loop.
P.S. This xsl code is a part of a bigger xsl file.
Any advice will be very helpful. Thanks in advance.
- Keyur
<!------------XSL Partial Code ------------>
<xsl:template match="//changes" mode="changeLog">
<!--firstName IS AVAILABLE HERE-->
<xsl:variable name="sortedList">
<xsl:for-each select="./old">
<xsl:sort select="@changeID" data-type="number" order="ascending"></xsl:sort>
<xsl:copy-of select="."></xsl:copy-of>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="msxsl:node-set($sortedList)/old">
<xsl:variable name="cID"><xsl:value-of select="@changeID"></xsl:value-of></xsl:variable>
<tr>
<!--firstName IS REQUIRED HERE BUT COULD NOT RETRIEVE-->
<td><xsl:value-of select="/wi:root/changeLog/log[@id = $cID]/@firstName" /></td>
<td><xsl:value-of select="./text()" /></td>
</tr>
</xsl:for-each>
</xsl:template>
<!------------XML Sample Code ------------>
<wi:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wi="abcxyz">
<content>
<personalData>
<lastName>Douglas</lastName>
<firstName>Michael</firstName>
<hobbies>
cricket, music, dancing, singing
<changes>
<old changeID="2">Hobbies</old>
<old changeID="4">cricket, music, dancing</old>
<old changeID="3">cricket, music</old>
</changes>
</hobbies>
</personalData>
</content>
<changeLog>
<log id="1" userID="8" firstName="Teri" date="8/13/2004" />
<log id="2" userID="7" firstName="Matt" date="8/13/2004" />
<log id="3" userID="15" firstName="Stephen" date="8/13/2004" />
<log id="4" userID="26" firstName="Bob" date="8/13/2004" />
</changeLog>
</wi:root>
[xsl] Newbie Problem
Subject: [xsl] Newbie Problem From: "Keyur K" <kkeyur@xxxxxxxxxxx> Date: Sat, 14 Aug 2004 10:53:39 +0000 |
Hello List,
I have a problem, I am not able to access any nodes/values from a Loop.
I have a sorted result tree fragment in a variable, I am using msxsl node-set to loop through it.
Now when I need to access the other nodes of the document I am not able to do so.
Pl. see below for the partial xsl and xml code. I have put two comments in the xsl file one where I need the external node values but not able to retrieve and second where I am able to retreive but do not need
How can I access the outer/external nodes inside the loop, I also tried using key() but it also didn't work inside the loop. It was working fine outside the loop.
P.S. This xsl code is a part of a bigger xsl file.
Any advice will be very helpful. Thanks in advance.
- Keyur
<!------------XSL Partial Code ------------>
<xsl:template match="//changes" mode="changeLog">
<!--firstName IS AVAILABLE HERE-->
<xsl:variable name="sortedList">
<xsl:for-each select="./old">
<xsl:sort select="@changeID" data-type="number" order="ascending"></xsl:sort>
<xsl:copy-of select="."></xsl:copy-of>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="msxsl:node-set($sortedList)/old">
<xsl:variable name="cID"><xsl:value-of select="@changeID"></xsl:value-of></xsl:variable>
<tr>
<!--firstName IS REQUIRED HERE BUT COULD NOT RETRIEVE-->
<td><xsl:value-of select="/wi:root/changeLog/log[@id = $cID]/@firstName" /></td>
<td><xsl:value-of select="./text()" /></td>
</tr>
</xsl:for-each>
</xsl:template>
<!------------XML Sample Code ------------>
<?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet type="text/xsl" href="abc.xsl"?>
<wi:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wi="abcxyz">
<content>
<personalData>
<lastName>Douglas</lastName>
<firstName>Michael</firstName>
<hobbies>
cricket, music, dancing, singing
<changes>
<old changeID="2">Hobbies</old>
<old changeID="4">cricket, music, dancing</old>
<old changeID="3">cricket, music</old>
</changes>
</hobbies>
</personalData>
</content>
<changeLog>
<log id="1" userID="8" firstName="Teri" date="8/13/2004" />
<log id="2" userID="7" firstName="Matt" date="8/13/2004" />
<log id="3" userID="15" firstName="Stephen" date="8/13/2004" />
<log id="4" userID="26" firstName="Bob" date="8/13/2004" />
</changeLog>
</wi:root>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Appended text = to a stri, cking | Thread | Re: [xsl] Newbie Problem, Mike Trotman |
Re: [xsl] Dynamically generating li, Dimtre Novatchev | Date | Re: [xsl] Newbie Problem, Mike Trotman |
Month |