[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: output an apostrophe

Subject: RE: output an apostrophe
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Fri, 1 Nov 2002 14:58:26 -0500
xsl apostrophe escape
[ aruniima.chakrabarti]

> but meanwhile I came with the problem that what if I want to 
> output the string 
> child::*[name()='label']/@val_id
> on screen... 

Sometimes the results can depend on the serializer that the xslt
processor uses.  For example, if the serializer normally places double
quotes around an attribute value, then when it encounters double quotes
within an attribute value it has to escape them.  You may have
encountered this behavior.

One way around this can be to use the other type of quote to embed in
your values.  Then the serializer does not need to escape them.  A
smarter serializer might insepct the attribute value first to figure out
what kind of quotes to use to avoid having to escape them.

For example, with my copy of Saxon,  I get these results -

<xsl:template match="/root">
	<element type=' "xxx" '/>
</xsl:template>

Result - 
<Saxon)         <element type=" &#34;xxx&#34; "/>
<Xalan)          <element type=" &quot;xxx&quot; "/>
(MSXSML3) <element type=" &quot;xxx&quot; " />
(XT)               <element type=" &quot;xxx&quot; "/>

<xsl:template match="/root">
	<element type=" 'xxx' "/>
</xsl:template>

Result - 
(Saxon, MSXML3, XALAN,XT) <element type=" 'xxx' "/>

On the other hand, for many or most purposes, it does not matter if the
quotes are escaped.  For example, the following generates the expected
output:

<name select="{&quot;xxx&quot;}"/>

And so does the following:

<xsl:template match="/">
   <name>
        <xsl:value-of select="name(*[name()=&quot;root&quot;])"/>
  </name>
</xsl:template>

This is to be expected since the parser will replace the character
references or entities with their replacement values before the xslt
processor sees them.

Cheers,

Tom P

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.