This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

getting the node position in source xml in a variable


Hi
I have a template which takes two node-sets as parameters. I loop thru one
of these nodeset using for-each and output the node value along with the
corresponding node in the second node-list.
Now the problem is that it works fine if i dont have a sort but with sort
only the first node list is sorted. So it takes the wrong corresponding
values from the second node-list.
because the position gives the position in the context. 
So i should use <xsl:number> but when i put the xsl:number in the variable
it always gives 1.
even the position() if inside <xsl:variable> gives always 1, but if used in
select attribute of <xsl:variable> it works fine

	<xsl:template name="lookup">
		<xsl:param name="name"/>
		<xsl:param name="datanodes"/>
		<xsl:param name="displaynodes"/>
		<select>
			<xsl:attribute name="name"><xsl:value-of
select="$name"/></xsl:attribute>
			<xsl:for-each
select="msxsl:node-set($displaynodes)">
				<xsl:sort select="."></xsl:sort>
				<xsl:variable name="num"
select="position()"/>
				<xsl:variable name="data"><xsl:value-of
select="msxsl:node-set($datanodes)[$num]"/></xsl:variable>
				<option id="{$data}" value="{$data}">
					<xsl:value-of
select="$data"/>-<xsl:value-of select="."/>
				</option>
			</xsl:for-each>
		</select>
	</xsl:template>

Thanks & Regards

Gurvinder
Amdocs Limited , Cyprus


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]