|
Subject:
|
<?javax.xml.transform.disable-output-escaping ?>
|
|
Posted By:
|
robbert
|
Post Date:
|
8/24/2006 1:10:05 PM
|
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 ?><script>...</script><?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 By:
|
mhkay
|
Reply Date:
|
8/25/2006 6:15:59 PM
|
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 By:
|
robbert
|
Reply Date:
|
8/27/2006 6:51:32 AM
|
Thanks Michael.
The "ContentHandler" is a DOM4J DocumentResult object in my case.
quote: This will only happen if you don't serialize the output directly.
I didn't understand that, sorry.
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 By:
|
mhkay
|
Reply Date:
|
8/27/2006 7:11:22 AM
|
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 By:
|
robbert
|
Reply Date:
|
8/27/2006 8:51:44 AM
|
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.
|