RE: [xsl] text nodes not merged

Subject: RE: [xsl] text nodes not merged
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 14 Sep 2006 16:22:49 +0100
You quote:

> According to http://www.w3.org/TR/xslt20/#constructing-complex-content
> (point 6 in the list there)

But you need to read the first paragraph of the section:

This section describes how the sequence obtained by evaluating a sequence
constructor may be used to construct the children of a newly constructed
document node, or the children, attributes and namespaces of a newly
constructed element node. The sequence of items may be obtained by
evaluating the sequence constructor contained in an instruction such as
xsl:copy, xsl:element, xsl:document, xsl:result-document, or a literal
result element.

So if you use the sequence returned by the function to construct the content
of an element, then adjacent text nodes will be merged. But if you don't
(for example if you do an xsl:for-each over the items in the sequence), then
they won't.

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


> -----Original Message-----
> From: Wolfgang Jeltsch [mailto:wolfgang@xxxxxxxxxxx] 
> Sent: 14 September 2006 16:13
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] text nodes not merged
> 
> Hello,
> 
> please consider this stylesheet:
> 
> 	<?xml version="1.0"?>
> 	<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> 		xmlns:example="http://www.example.com/";
> 		version="2.0">
> 	  <xsl:function name="example:double-text">
> 	    <xsl:param name="node"/>
> 	    <xsl:value-of select="$node"/>
> 	    <xsl:text>#</xsl:text>
> 	  </xsl:function>
> 	  <xsl:template match="/">
> 	    <hello>
> 	      <xsl:for-each select="example:double-text(/)">
> 	        <hi>
> 	          <xsl:value-of select="."/>
> 	        </hi>
> 	      </xsl:for-each>
> 	    </hello>
> 	  </xsl:template>
> 	</xsl:stylesheet>
> 
> According to http://www.w3.org/TR/xslt20/#constructing-complex-content
> (point 6 in the list there), the two text nodes created by 
> the function's sequence constructor should be merged, as far 
> as I can see.  However, they aren't which is shown by the 
> fact that the stylesheet outputs two hi elements instead of 
> one.  What's wrong here?
> 
> By the way, I use the open-source edition of Saxon 8.7.3J on 
> Debian GNU/Linux 3.1.
> 
> Best wishes,
> Wolfgang

Current Thread