[xsl] <xsl:key> problem

Subject: [xsl] <xsl:key> problem
From: "Jan Weiss" <jweiss@xxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Aug 2001 14:54:17 +0200
hi all,

perhaps i put <xsl:key> at the wrong place??
what else could be the reason that this would not work??

i want to group my xml by bct_art_nr and get an output where all bct_index
are together if they have unique bct_art_nr:

i want to get:
<row>
	<articlenr>123</articlenr>
	<index> 2 </index>
	<index> 1 </index>
	<index> 0 </index>
</row>
<row>
	<articlenr>456</articlenr>
	<index> 3 </index>
	<index> 2 </index>
	<index> 1 </index>
</row>





my xml structure to transform:

<results>
	<row>
		<@db.bct_dm_t01.bct_art_nr>123</@db.bct_dm_t01.bct_art_nr>
		<@db.bct_mod_t02.bct_index>2  </@db.bct_mod_t02.bct_index>
	</row>
	<row>
		<@db.bct_dm_t01.bct_art_nr>123</@db.bct_dm_t01.bct_art_nr>
		<@db.bct_mod_t02.bct_index>3  </@db.bct_mod_t02.bct_index>
	</row>
	<row>
		<@db.bct_dm_t01.bct_art_nr>456</@db.bct_dm_t01.bct_art_nr>
		<@db.bct_mod_t02.bct_index>1  </@db.bct_mod_t02.bct_index>
	</row>
</results>

my xsl file:
<!-- top-level -->
<xsl:key name="row-by-artnr" match="row" use="@db.bct_dm_t01.bct_art_nr"  />

<xsl:template match="results">


<Abfrageergebnisse>
<xsl:for-each
select="row[count(.|key('row-by-artnr',@db.bct_dm_t01.bct_art_nr)[1]) = 1]">


   		<col>
			<xsl:variable name="nummer" select="@db.bct_dm_t01.bct_art_nr"/>

      		<artnr nummer="{$nummer}">
	<index><xsl:copy-of select="key('row-by-artnr',@db.bct_dm_t01.bct_art_nr)/
@db.bct_mod_t02.bct_index" />
	</index>
   			</artnr>
    		</col>



		</xsl:for-each>

	</Abfrageergebnisse>
</xsl:template>









very 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