Re: [xsl] Processing multiple lists

Subject: Re: [xsl] Processing multiple lists
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Wed, 07 Sep 2005 19:00:49 +0200
Tempore 17:00:22, die 09/07/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Emerson, Matt <Matt.Emerson@xxxxxxx>:

That seems like a reasonable approach.  Do you know how I could
construct the string from the nodeset?

Suppose the input is:


<root>
	<list1>
		<node id="1">....stuff....</node>
		<node id="2">....stuff....</node>
		<node id="3">....stuff....</node>
		<node id="4">....stuff....</node>
		<node id="5">....stuff....</node>
		<node id="6">....stuff....</node>
	</list1>
	<list2>
		<node id="1">....stuff....</node>
		<node id="2">....stuff....</node>
		<node id="3">....stuff....</node>
		<node id="4">....stuff....</node>
		<node id="5">....stuff....</node>
		<node id="6">....stuff....</node>
	</list2>
	<list3>
		<node id="1">....stuff....</node>
		<node id="2">....stuff....</node>
		<node id="3">....stuff....</node>
		<node id="4">....stuff....</node>
		<node id="5">....stuff....</node>
		<node id="6">....stuff....</node>
	</list3>
</root>

Than you can construct the test-result string with:

<xsl:variable name="test-result">
	<xsl:for-each select="/root/list2/node">
		<xsl:value-of select="number(@id mod 2=0)"/>
	</xsl:for-each>
</xsl:variable>

The test itself is contained inside the 'number()' function. In this example it checks wether the id number is even or odd, producing '010101'

('1' and '0' are easier to construct than 'Y' and 'N' - no additional tests needed)

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
B+In the land of the blind, the one-eyed man is kingB;

Current Thread