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

RE: Output escaped characters that represent the CR as

Subject: RE: Output escaped characters that represent the CR as an attribute
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 29 Sep 2004 21:00:29 +0100
xml escape characters
The following stylesheet

<TagwithAttribute att1="XXXX&#x0D;&#x0A;YYYY"
xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>

when run against any source document, produces the output (from Saxon 8.1)

<?xml version="1.0" encoding="UTF-8"?>
<TagwithAttribute att1="XXXX&#xD;&#xA;YYYY"/> 

I can't imagine the leading zeroes are really essential to your application.

The XSLT serializer ought to escape any CR and NL characters in the
attribute value. The 1.0 spec specifically mentions this in the case of NL
characters. It isn't explicit about it in the case of CR, but it is implicit
in the general requirement that the serializer should produce a
representation that "round-trips": i.e. that regenerates the identical
result tree when parsed.

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


> -----Original Message-----
> From: good all [mailto:good2all@xxxxxxxxx] 
> Sent: 29 September 2004 19:42
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Output escaped characters that represent the 
> CR as an attribute
> 
> Hi, all,
> 
> I have a requirement to out the escaped characters that represent the
> CR as an attribute.What I want is:
> 
> <TagwithAttribute att1="XXXX&#x0D;&#x0A;YYYY"/>
> 
> Regards an old posts in this list, we can output these characters as:
> <xsl:text 
> disable-output-escaping="yes">XXXX&amp;#x0D;&amp;#x0A;YYYY</xsl:text>
> 
> However, this works fine to element only, doesn't work if I want to
> assgin this to an attribute.Please see the following files.
> 
> Any replys are highly appreciated.
> 
> thanks.
> Good2all
> 
> Source XML File:
> ------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl" href="x0Dx0A_Test.xslt"?>
> <dummy/>
> 
> ------------------
> XSLT file:
> --------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format">
> <xsl:template match="/">
> <someTag>
> 	<xsl:text 
> disable-output-escaping="yes">XXXX&amp;#x0D;&amp;#x0A;YYYY</xsl:text>
> 	<tagwithattri>
> 		<xsl:attribute name="att1">
> 			<xsl:text 
> disable-output-escaping="yes">XXXX&amp;#x0D;&amp;#x0A;YYYY</xsl:text>
> 		</xsl:attribute>
> 	</tagwithattri>
> </someTag>
> </xsl:template>
> </xsl:stylesheet>
> 
> 
> --------------------
> Output XML File:
> ----------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <someTag 
> xmlns:fo="http://www.w3.org/1999/XSL/Format">XXXX&#x0D;&#x0A;YYYY
> <tagwithattri att1="XXXX&amp;#x0D;&amp;#x0A;YYYY"/>
> </someTag>
> 
> ----------------------
> 
> --+------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --+--

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.