XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Justin KohlheppSubject: Keep escaped chars escaped in output
Author: Justin Kohlhepp
Date: 19 Apr 2007 01:19 PM
I am generating Excel XML from an XML which has the business data I want to insert. Some of the values in the business data have carraige returns which I want to appear in the Excel app in the end. The Excel XML format maintains carraige returns in its format as &#10;, like this: <Data>Line 1 &#10; Line 2</Data>

But if I put something like this in my source XML doc, <field>My&#10;Value</field>, it gets rendered to the Excel XML like this:
<Data>My
Value</Data>
Excel renders that as a space.

How do I prevent XSLT from unescaping the escaped chars in my source XML?

Thanks,

~ Justin

Postnext
Tony LavinioSubject: Keep escaped chars escaped in output
Author: Tony Lavinio
Date: 23 Apr 2007 09:09 PM
It's not XSLT that undoes it, but the XML parser.
By the time XSLT, or any XML-related processor, sees the
input, there are no escapes - only translated data.
So &#10; and &#xa; and &#x000a; and a literal linefeed
all look the same.

One thing you can control (if you are using XSLT 2.0) is
how certain characters are output. You can try using
the xsl:character-map feature. You could set it up so
that anywhere you want an explicit &#10; you instead write
something else, like &xE00E; to the output, and use the
character map to translate back.

Postnext
Justin KohlheppSubject: Keep escaped chars escaped in output
Author: Justin Kohlhepp
Date: 30 Apr 2007 04:09 PM
Originally Posted: 30 Apr 2007 04:08 PM
Tony,

Thanks for the help, but I'm afraid I'm still a bit confused. I have my XML source doc and the XSLT I'm going to run it through. In the XSLT I have an xsl:value-of which should output the text of a node in the source doc. Sometimes, in the *result* doc I need the characters &#10; so Excel can open it and translate it to a newline in a cell. What do I put in the source doc and XSLT to get this to happen?

I tried to have the source doc have a <node>LINE 1$mynewline;LINE2</node> with a <xsl:character-map><xsl:output-character character="&mynewline;" string="&amp;nbsp;" /></xsl:character-map> in my XSLT, but I got an error saying entity &mynewline; is not declared.

Thanks,

~ Justin

Posttop
Justin KohlheppSubject: Keep escaped chars escaped in output
Author: Justin Kohlhepp
Date: 30 Apr 2007 04:36 PM
Ah. It looks like my real problem is that .NET ignores disable-output-escaping sometimes as discussed here:
http://www.stylusstudio.com/SSDN/default.asp?action=9&fid=48&read=3311

Now I don't know what to do. Having <node>Line 1&amp;#10;Line 2</node> and then an <xsl:value-of select="node" disable-output-escaping="yes"/> will correctly output Line 1&#10;Line 2 in everything but the processor I'm forced to use. :-(

Thanks for the help,

~ Justin

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.