Re: [xsl] position() oddity?

Subject: Re: [xsl] position() oddity?
From: Joe English <jenglish@xxxxxxxxxxxxx>
Date: Wed, 28 Feb 2001 20:15:19 -0800
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


 XSL-List info and archive:

Current Thread