RE: [xsl] "Passing through" special characters

Subject: RE: [xsl] "Passing through" special characters
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 27 Jan 2005 18:22:30 -0000
First point: the character references such as &#10; are converted to regular
characters by the XML parser. The XSLT processor never gets to see the
character references, so it can't pass them through.

Second point: character references such as &#10; are a feature of XML and
HTML, so you can produce them when using the xml and html output methods,
but not when using the text output method. Characters are never escaped with
the text output method, so disabling escaping achieves nothing.

I think you need to use something like (in XPath 2.0) replace('&#10;',
'&amp;#10;')

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

> -----Original Message-----
> From: David.McKay@xxxxxxxxxxxxxxxxxxxxxxxxxxx 
> [mailto:David.McKay@xxxxxxxxxxxxxxxxxxxxxxxxxxx] 
> Sent: 27 January 2005 15:56
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] "Passing through" special characters
> 
> --- XSL Processor Details
> 
> Vendor: SAXON 6.5.3 from Michael Kay
> Vendor URL: http://saxon.sf.net/
> 
> ---
> 
> I have some xml, the important part of which looks like this:
> 
> <RS422Tx name="RS422Tx1" baud_rate="19200" 
> data_word="ABC&#13;&#10;DEF&#13;&#10;"/>
> 
> I am trying to parse to a text output file. Problem is, I 
> can't figure out a way to generate the following:
> 
> CALCULATE, TX$="ABC&#13;&#10;DEF&#13;&#10;"
> 
> This:
> 
> <xsl:if test="@data_word">CALCULATE, TX$="<xsl:value-of 
> select="@data_word"/>"</xsl:if>
> 
> results in:
> 
> CALCULATE, TX$="ABC
> DEF
> "
> 
> I tried both settings of disable-output-escaping, neither of 
> which seemed to make a difference.
> 
> 
> There may also be a requirement to output as follows:
> 
> CALCULATE, TX$="ABC"+CHR$(13)+CHR$(10)+"DEF"+CHR$(13)+CHR$(10)
> 
> 
> Can anyone offer any hints for either problem?
> 
> Thanks.
> 
> Dave McKay
> 
> 
> 
> **********************************************************************
> IMPORTANT NOTICE
> 
> The information contained in this e-mail is confidential. It may also 
> be legally privileged. It is intended only for the stated 
> addressee(s) 
> and access to it by any other person is unauthorised. If you are not 
> an addressee, you must not disclose, copy, circulate or in any other 
> way use or rely on the information contained in this e-mail. Such 
> unauthorised use may be unlawful.
> 
> If you have received this e-mail in error, please inform 
> Racal Instruments Group Ltd. immediately by 
>     emailing  postmaster@xxxxxxxxxxxxxxxxxxxxxxxxxxx 
> or 
>     phoning +44 (0)1202 872800  (ask for the I.T. Dept.) 
> and delete it and all copies from your system.
> 
> www.racalinstrumentsgroup.co.uk
> 
> **********************************************************************

Current Thread