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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.