[xsl] adressing attributes

Subject: [xsl] adressing attributes
From: Michael Zehrer <zehrer@xxxxxxxxxxxxxxxxxx>
Date: Fri, 29 Jun 2001 12:31:05 +0200
Thanks to the FAQ I learned howto "Making balanced two-column tables from
one-column data", but I also want to list one attribute and really don't
know how to address it. 

This is my XML:

<page>
	<element id="sometext">content</element>
	...
</page>

and my XSL is:

<xsl:variable name="t-size" select="count(//element)"/>
<xsl:variable name="half" select="ceiling($t-size div 2)"/>
		   
<table>
	<xsl:for-each select="//element[position() &lt;= $half]">
	<xsl:variable name="here" select="position()"/>
	<tr>
	<td><xsl:value-of select="@id"/></td>
	<td><xsl:value-of select="."/></td>
	<td><xsl:value-of select="@id"/></td>
	<td>
	<xsl:choose>
		<xsl:when test="../element[$here+$half]">
			<xsl:value-of select="../element[$here+$half]"/>
		</xsl:when>
		<xsl:otherwise></xsl:otherwise>
	</xsl:choose>
	</td>
	</tr>
	</xsl:for-each>
</table>

Sure, at the moment the @id in the 3rd cell gives the same value as the one
in the first cell, but it should contain the value of the id attribute of
the 4th cell element. I tried to construct something similar to the 4th cell
xsl code, but it just don't work. Can someone explain it to me?

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


Current Thread