Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 24th, 2006, 01:10 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default <?javax.xml.transform.disable-output-escaping ?>

Hi there, I'm using javax.xml.transform.Transformer.TransformerFactory to transform an XML document by an XSLT document.

In the XSLT document, there are commands like,
<xsl:text disable-output-escaping="yes"><![CDATA[
<script>...</script></xsl:text>


The resulting document will look like,
<?javax.xml.transform.disable-output-escaping ?>&lt;script&gt;...&lt;/script&gt;<?javax.xml.transform.disable-output-escaping ?>

I've already Google'd for that, extensively - and found several related posts - but not a solution...

Thanks
Robert


Reply With Quote
  #2 (permalink)  
Old August 25th, 2006, 06:15 PM
mhkay's Avatar
Wrox Author
Points: 17,773, Level: 58
Points: 17,773, Level: 58 Points: 17,773, Level: 58 Points: 17,773, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,839
Thanks: 0
Thanked 267 Times in 262 Posts
Default

The JAXP interface specifies that disable-output-escaping requests are passed in this way from the XSLT transformer to a user-written ContentHandler. This will only happen if you don't serialize the output directly. It's best not to use d-o-e unless you are serializing the output (actually, it's best not to use it at all).

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old August 27th, 2006, 06:51 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael.

The "ContentHandler" is a DOM4J DocumentResult object in my case.
Quote:
quote:This will only happen if you don't serialize the output directly.
I didn't understand that, sorry.
Quote:
quote:It's best not to use d-o-e unless you are serializing the output (actually, it's best not to use it at all).
In my understanding, using d-o-e breaks the rule that the XSL transformer should be able to produce the result tree in one pass. A second pass will be necessary.

Nevertheless, it's obvious that I need to integrate the <script> tags into the document, at any rate...

Are common techniques to accomplish that?

Reply With Quote
  #4 (permalink)  
Old August 27th, 2006, 07:11 AM
mhkay's Avatar
Wrox Author
Points: 17,773, Level: 58
Points: 17,773, Level: 58 Points: 17,773, Level: 58 Points: 17,773, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,839
Thanks: 0
Thanked 267 Times in 262 Posts
Default

disable-output-escaping is an instruction to the serializer, that is the component that turns the result tree into lexical XML. If your result is not lexical XML but a DOM4J DocumentResult, then d-o-e has no meaning. The XSLT 2.0 spec says that in such cases it should be ignored. But the JAXP spec takes into account that when you send to a ContentHandler, the ContentHandler might be acting as a serializer and might want to know about the request to disable-output-escaping. So it defines this processing instruction to convey the request.

Why are you generating the script element as text, rather than as a regular element node? This is the root of your trouble: you're thinking in terms of generating lexical XML rather than generating a result tree.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #5 (permalink)  
Old August 27th, 2006, 08:51 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Why are you generating the script element as text, rather than as a regular element node? This is the root of your trouble
Muhahaha! That one's cured! - Thanks!

Also thanks for the background information. I was coming from the Microsoft world - that, I think, says it all.

Reply With Quote
  #6 (permalink)  
Old January 5th, 2011, 06:28 PM
Registered User
 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default follow these simple steps to get rid of that

Use a StreamResult parser, insetad of DOMResult
transformer.setOutputProperty(OutputKeys.OMIT_XML_ DECLARATION,"yes");
if you are working with only part of the html page.

You should be set.

Mark
http://www.nosle.com
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I transform XSLT without the <?xml?> tag? nadavvin XSLT 4 June 10th, 2007 09:25 AM
Finding an alternative to disable-output-escaping nickbond XSLT 4 November 15th, 2006 04:28 PM
Disable-Output-Escaping in .NET Transform tclancy XSLT 3 March 1st, 2006 08:27 AM
Escaping < and > barnaclebarnes XSLT 4 October 5th, 2004 08:56 AM
copy-of with disable-output-escaping? andrin XSLT 5 July 16th, 2004 04:46 AM



All times are GMT -4. The time now is 05:05 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.