[xsl] opposite of preceding-sibling

Subject: [xsl] opposite of preceding-sibling
From: "Jan Weiss" <jweiss@xxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Aug 2001 14:47:23 +0200
hi all

i am in a xml structure like:

<test>
	<result>
		<row>
			<artnr>gh</artnr>
			<index>hk</index>
		</row>
		<row>
			<artnr>gh</artnr>
			<index>hk</index>
		</row>
	</result>
<test>

i want to compare the <artnr> .

i'd like to get an output in xml like this.

<test>
	<list>
		<col>
			<artnr>
				<index>
				<index>    if the artnr of the different rows are equal
				<index>
			</artnr>
		</col>
		<col>
			<artnr>
				<index>    if the artnr are different theres only the current index
			</artnr>
		</col>

i am not able to access the <artnr> tag a second time to put in a new index.


<xsl:template match="row">



<xsl:if test="not(preceding-sibling::row[1]/artnr = artnr)">
	<col>
		<xsl:variable name="nummer" select="artnr"/>
		<artnr nummer="{$nummer}">

			<xsl:call-template  name="row3"/>

		</artnr>
	</col>
</xsl:if>


<xsl:if test="(preceding-sibling::row[1]/artnr = artnr)">

	<xsl:call-template  name="row3"/>

</xsl:if>

<xsl:apply-templates mode="row1"/>
</xsl:template>


<xsl:template name="row3">


	<Index>
		<xsl:value-of select="index"/>
	</Index>

<xsl:apply-templates mode="row1"/>

</xsl:template>


hopefully


jan



Jan Weiss
IT - Student
BCT Technology AG
Im Lossenfeld 9
D-77731 Willstaett

Tel: +49-7852-996-237
Fax:+49-7852-996-100

mailto:jweiss@xxxxxxxxxxxxxxxxxx
http://www.bct-technology.com
http://www.bct-portal.com



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


Current Thread