RE: [xsl] function text()

Subject: RE: [xsl] function text()
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Mon, 15 Oct 2001 16:47:04 +0100
It works right in Xalan and Saxon and wrong in MSXML3.

xsl:value-of select="text()" selects the first child text node. If you
haven't stripped whitespace text nodes, this will be whitespace. MSXML3
strips the whitespace without you asking it to. According to the XSLT spec,
you should specify <xsl:strip-space elements="*"/> to get this effect.

But actually, it would be better not to rely on the text node you want being
the first one. It's safer to output all of them:

replace <xsl:value-of select="text()"/>
by <xsl:copy-of select="text()"/>

Mike Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Ursprung
> Manfred
> Sent: 15 October 2001 16:15
> To: XSL-list (E-Mail)
> Subject: [xsl] function text()
>
>
> Hi all,
>
> function text() doesn't work right in Xalan (Java) and in Saxon.
> With MSXML3 it works fine, but I need a Java based processor.
>
> My XML-document looks like :
> <formalpara>
>         <title>
>           <token> §1 </token>
>         Chapter 1
>         </title>
> </formalpara>
>
> XSL looks:
> <xsl:template match="title" mode="next">
>     <fo:table-row>
>       <fo:table-cell padding-after="4mm" padding-before="4mm">
>         <fo:block font-weight="bold">
>           <xsl:value-of select="token"/>
>         </fo:block>
>       </fo:table-cell>
>       <fo:table-cell>
>         <fo:block font-weight="bold" padding-after="4mm"
> padding-before="4mm">
>           <xsl:value-of select="text()"/>
>         </fo:block>
>       </fo:table-cell>
>     </fo:table-row>
>   </xsl:template>
>
> With MSXML3 I get :  §1 Chapter 1
> but with Xalan or Saxon I get only: §1
> Using <xsl:value-of select="."/> instead of <xsl:value-of
> select="text()"/>
> I get:
>   §1 §1 Chapter1
>
> Does anyone can help ?
>
> - Manfred
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread