This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: position() oddity?



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]