[xsl] Another beginner question about position() counting using recursi ve templates

Subject: [xsl] Another beginner question about position() counting using recursi ve templates
From: "Braumüller, Hans" <h.braumueller@xxxxxxxxxxxx>
Date: Mon, 8 Apr 2002 17:15:12 +0200
Hello,

the search at our archives are a mess. So excuse my FAQ-like question about
position() using recursive templates.

I want counting all cols from 1 to 8 and then assigning every number to an
id attrribute, idependent from their relative context node.
I am trying to assign a parameter and then select this  <xsl:value-of
select="$datacells" />.

Now i am getting 1 2 3 4
		   1 2 3 4

which is no wonder because that is in fact the position() relative to the
context node.

I have no idea how to get the param datacells outputting:

		1 2 3 4
		5 6 7 8

Please consider, that i want stay with the recursive model instead of using
an procedual for-each approach.

Thank you very much, for your help and excuse my beginner question.

here my source:

<?xml version="1.0"   encoding="ISO-8859-1"  ?>
<?xml:stylesheet href="prototyp5.xsl" type="text/xsl"?>
<tabelle>
<row id="r0">
	<col name="bspnr" id="r0_c0">b</col>
	<col name="date"  id="r0_c1">01.01.2001</col>
	<col name="gspnr" id="r0_c2">4711</col>
	<col name="isocode" id="r0_c3">USD</col>
	
</row>
<row id="r1">
	<col name="bspnr" id="r1_c0">a</col>
	<col name="date"  id="r1_c1">12.12.2002</col>
	<col name="gspnr"  id="r1_c2">47122</col>
	<col name="isocode" id="r1_c3">EUR</col>
	
</row>
</tabelle>

------------------
here my xsl stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
		<html>
			<head>
				<title>tabelle.xsl</title>
			</head>
			<body bgcolor="#cccccc" text="#000000"
link="#455fbe" vlink="#455fbe" alink="#FF9900" topmargin="0" leftmargin="0"
marginheight="0" marginwidth="0" id="output">
				<div align="center">
					<xsl:apply-templates
select="tabelle"></xsl:apply-templates>
				</div>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="tabelle">
		<table cellpadding="0" cellspacing="0" border="1"
align="center">
			<xsl:apply-templates select="row">
			</xsl:apply-templates>
		</table>
	</xsl:template>
	<xsl:template match="row">
		<tr>
			<xsl:attribute name="id">
				<xsl:number value="position()" format="1" />
			</xsl:attribute>
			<xsl:apply-templates
select="col"></xsl:apply-templates>
		</tr>
	</xsl:template>
	<xsl:template match="col">
		<xsl:param name="datacells" select="position()"></xsl:param>
		<td>
			<xsl:attribute name="name">
				<xsl:value-of select="@id" />
			</xsl:attribute>
			<xsl:attribute name="id">
				<xsl:value-of select="$datacells" />
			</xsl:attribute>
				<xsl:value-of select="." />
		</td>
	</xsl:template>
</xsl:stylesheet>

Thanks,

 
Hans Braumüller 
Networking Artist
http://braumueller.crosses.net


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


Current Thread