[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Subject: Counting Path Occurrences


Subject: RE: [xsl] Subject: Counting Path Occurrences
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 4 Apr 2007 08:28:11 +0100

> > Actually that function generates a sequence of text nodes.
> 
> That was the original source of my confusion.  :)  Is that 
> because of the "for-each" over the ancestor-or-self axis?  
> 

The select clause of the for-each is irrelevant. It's because the content of
the xsl:for-each is an xsl:value-of instruction. xsl:value-of constructs a
text node, therefore xsl:for-each constructs several text nodes.

If you use this construct inside another instruction such as a literal
result element, then the several text nodes will be concatenated. But used
directly within a function, there's no containing instruction to do the
concatenation, so the sequence of text nodes is returned as is.

Very often in 2.0 you should be using xsl:sequence rather than xsl:value-of.
The difference is that xsl:sequence returns the result of its select
expression unchanged, whereas xsl:value-of flattens it into a string and
then wraps that string in a text node.

Michael Kay
http://www.saxonica.com/


Current Thread