This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: first of type element position
- From: "Sébastien Tisserant" <stisserant at europarl dot eu dot int>
- To: <jeni at jenitennison dot com>
- Cc: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 12 Mar 2002 11:42:59 +0100
- Subject: Re: [xsl] first of type element position
- Reply-to: xsl-list at lists dot mulberrytech dot com
thanks jeni,
your propositions work.
but is it possible with indicating the position and the element name in the test
like this:
<xsl:if test=".[self::TOC.SECT][position()!=1]">
i have already use *[self::TOC.SECT][1] (with the same kind of problem) in a template match and it worked well.
thanks again for your always detailed and rich explanations.
Sébastien
>>> Jeni Tennison <jeni@jenitennison.com> 03/12/02 11:18 >>>
Hi Sébastien,
> <xsl:if test="position()!=1"> doesn't work because, i think, the
> first element <TOC.SECT> is in position()=2. and <TI.TOC> in
> position()=1.
You can test whether the TOC.SECT has a preceding sibling TOC.SECT
element:
<xsl:if test="preceding-sibling::TOC.SECT">
<!-- not the first TOC.SECT element -->
...
</xsl:if>
Or you could change the way that you apply templates to the elements,
so that the position() test would work. If you did:
<xsl:template match="RP.TOC">
...
<xsl:apply-templates select="TI.TOC" />
<xsl:apply-templates select="TOC.SECT" />
...
</xsl:template>
Then in the template matching the TOC.SECT elements, the set of nodes
to which you were applying templates would only contain TOC.SECT
elements, and the node in position 1 would be the first of those
TOC.SECT elements.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list