[xsl] text() vs xs:string serialization (was: Re: [xsl] text extraction)

Subject: [xsl] text() vs xs:string serialization (was: Re: [xsl] text extraction)
From: "James A. Robinson" <jim.robinson@xxxxxxxxxxxx>
Date: Thu, 12 Oct 2006 07:09:57 -0700
This is awful form,  but I'm going to respond to my own answer
with a question.  One of the things I played around with when
writing the message below was how the serialization handled
separation of the output sequences.

Am I correct in my understanding that the reason the stylesheet
below works, separating each item from the <xsl:sequence/> with
a single whitespace character, is due to

 http://www.w3.org/TR/xslt-xquery-serialization/#serdm

where a sequence of strings will be padded, but a sequence of
text nodes will not be?  In other words, is that reference
above the reason that either

  <xsl:sequence select="string(.)"/>

or

  <xsl:sequence select="normalize-space(.)"/>

work, giving, 'text1 text2 text3', whereas

  <xsl:sequence select="."/> <!-- selecting text() node -->

would result in 'text1text2text3' ?
 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">
>   <xsl:output method="text"/>
>   <xsl:template match="node()">
>     <xsl:apply-templates select="node()"/>
>   </xsl:template>
>   <xsl:template match="text()[parent::*[self::E1|self::E2]]">
>     <xsl:sequence select="normalize-space(.)"/>
>   </xsl:template>
> </xsl:stylesheet>
> 
> That would let you handle, for example, something like
> 
> <V><E1>text<E2>text2<baz>smorth</baz></E2>text3<flober>chum</flober></E1></V>
> 
> Jim
> 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> James A. Robinson                       jim.robinson@xxxxxxxxxxxx
> Stanford University HighWire Press      http://highwire.stanford.edu/
> +1 650 7237294 (Work)                   +1 650 7259335 (Fax)
> 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       jim.robinson@xxxxxxxxxxxx
Stanford University HighWire Press      http://highwire.stanford.edu/
+1 650 7237294 (Work)                   +1 650 7259335 (Fax)

Current Thread