This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: position() of a current node
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] position() of a current node
- From: Daniel Bauke <bonkey at sokrates dot mimuw dot edu dot pl>
- Date: Fri, 15 Jun 2001 16:18:53 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
On Friday (Jun 15), Michael Kay wrote:
> I'm confused too, because your sections aren't part of a chapter, they are
> part of a part.
>
> Getting position() values of 2,4,6 or 1,3,5 is usually because you are
> processing the whitespace nodes between elements as well as the elements.
> This doesn't seem to be the case in your example.
>
> Please post a complete stylesheet and tell us which processor you're using.
well, it quite complicated, i'll try to reproduce it as simple as
possible, but i suspect it's sth exacly with whitespaces.
<!-- XSLT (using Cocoon 1.8) -->
<xsl:template match="/">
<xsl:apply-templates/>
</xslt:template>
<xsl:template match="document">
<html><body>
<xsl:apply-templates select="//chapter[@id = $chapter]"/>
</body></html>
</xslt:template>
<xsl:template match="chapter"> <!-- i've forgot to put it in
earlier example-->
<!-- ... -->
<xsl:for-each select="section">
<li>
<a> <xsl:attribute name="href">sect<xsl:value-of select="position()"/></xsl:attribute> </a>
<xsl:value-of select="@title"/>
</a></li>
</xsl:for-each>
<!-- ... -->
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="chapter">
<a> <xsl:attribute name="name">sect<xsl:value-of select="position()"/></xsl:attribute> </a>
<h3><xsl:value-of select="@title"/></h3>
<xsl:apply-templates/>
</xsl:template>
<!-- XML: -->
<document style="xxx">
<part title="xxx" url="xxx" toc="xxx">
<chapter shortname="xxx" id="xxx">
<TOC title="xxx"/>
<center>
<para> <link href="xxx"></link> </para>
<para> <link href="xxx"></link> </para>
</center>
</chapter>
</part>
<part title="xxx" url="xxx">
<chapter title="xxx" shortname="xxx" id="xxx">
<includescript type="xxx" file="xxx"/>
<includescript type="xxx" file="xxx"/>
<includescript type="xxx" file="xxx"/>
<includescript type="xxx" file="xxx"/>
<section title="xxx">
<para>
</para>
</section>
<section title="xxx">
<para>
</para>
<para>
</para>
</section>
</chapter>
</part>
</document>
(i hope i didn't cut too much :-)
--
Daniel `bonkey' Bauke; http://www.oho.pl/~bonkey/; {happiness=bike&&unix;}
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list