Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2006, 06:55 PM
Authorized User
 
Join Date: Jan 2006
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Disable-Output-Escaping in .NET Transform

I have a question before I go any further down my current path. I have an XML document that describes the layout of an HTML form. I'm transforming it with XSL. That all works fine. I'm running into a problem when I try to add the value of the form field into the XML document (you know what's coming): one of the fields will contain HTML that may not be well-formed.

I'm dumping the HTML value into a CDATA section to handle the escaping and the non-well-formedness on the XML side. On the transform back to HTML, I'm grabbing the value via this bit of XSL:

<xsl:value-of select="/page/contents/maincontent/item/text()" disable-output-escaping="yes"/>

I've tried a number of different ideas (there are at least 155,000 of them in Google for "xsl transform cdata section html"), but the resulting HTML is always escaped. Is this because I'm dynamically creating the XML document in memory?

This is in C# on the .NET 2.0 framework.

 
Old February 28th, 2006, 07:37 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

disable-output-escaping only works if the output of the transformation is serialized using the XSLT serializer (and if the serializer supports it - not all do). I think the System.Xml.Xsl serializer supports d-o-e, but if you write the transformation output to a DOM tree, that's not much use.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 1st, 2006, 08:45 AM
Authorized User
 
Join Date: Jan 2006
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

(I have successfully used d-o-e before with a System.Xml.Xsl transformation, so I don't think that's it.)

if you write the transformation output to a DOM tree, that's not much use

You lost me there. What do you mean by writing the transformation to a DOM tree? Here's my current process as best I can describe it. I am:

1. Reading an XML file from disk.
2. Inserting content elements into it while in memory.
3. Transforming the updated document via XSL.
4. Returning the result as a string . . .

Having just walked through my code with a few choice breakpoints to make sure I wasn't lying, it appears the problem occurs after step 4, so it's not the transformation at all. Thanks for helping me see that.

 
Old March 1st, 2006, 09:27 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I don't know the details of System.Xml.Xsl, but by analogy with other APIs I imagine that if you use a method like

public XmlReader Transform(XPathNavigator, XsltArgumentList, XmlResolver);

then the result isn't going to be serialized and disable-output-escaping is likely to have no effect.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
<?javax.xml.transform.disable-output-escaping ?> robbert XSLT 5 January 5th, 2011 07:28 PM
Finding an alternative to disable-output-escaping nickbond XSLT 4 November 15th, 2006 05:28 PM
recursive transform output different in IE and FF seamus7 XSLT 2 January 20th, 2006 06:01 PM
Removing Namespaces from XSL Transform output francislang XSLT 2 September 7th, 2004 07:58 AM
copy-of with disable-output-escaping? andrin XSLT 5 July 16th, 2004 04:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.