This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: position() oddity?
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] position() oddity?
- From: Joe English <jenglish at flightlab dot com>
- Date: Wed, 28 Feb 2001 20:15:19 -0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
Peter Flynn wrote:
> Given test.xml
> [...]
> what would you expect position() in template match "headers/title" to
> return?
It depends entirely on how the template was invoked.
('match="headers/title"'; is a red herring; the template's
match expression doesn't affect the context node position
in any way.)
> Currently it returns 2 4 6 8 10 using test.xsl (appended) when
> run through xt and cocoon. It's not quite what I expected (1 2 3 4 5 :-)
In this case, the template in question is invoked by
an <xsl:apply-templates/> instruction when the context node
is the 'headers' element. <xsl:apply-templates/> is shorthand
for <xsl:apply-templates select="child::node()"/>, so the context
node list contains all the children of the <headers> element,
namely, an alternating sequence of text nodes (containing whitespace)
and <title> element nodes.
<xsl:strip-space elements="header"/> should give the expected answer,
as will <xsl:apply-templates select="child::title"/>.
--Joe English
jenglish@flightlab.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list