Subject: Re: [xsl] Preserve HTML formatting when apply-templates in variabl From: Chris Loschen <closchen@xxxxxxxxxxxxxxxxxx> Date: Fri, 06 Aug 2004 12:33:35 -0400 |
This raises an issue I've been struggling with as well. I've been reading this list for several years now and have seen numerous threads about avoiding d-o-e if at all possible. I've almost always been able to avoid it, and I've even rooted out as much of it as I can from the code I've corrected for others. But I've just used it in my current project, and I'm not sure if there was another approach I could have used.
Here's the situation: I've got a very large input file which would overflow my memory if I ran the XSLT all at once. So instead I'm breaking up the file into smaller pieces and running each one separately. More specifically, the file is set up like
and I need to process the header, each individual bill, and finally the trailer in a series of XSLT transforms, usually more than a thousand all told. However, I do need to retain some of the data from the transforms as I go because I need to include a grand total of the amount billed and the total number of records in the trailer data.
<xalan:write file="bills.xml"> <xsl:text disable-output-escaping="true"><root></xsl:text> </xalan:write>
<xalan:write file="bills.xml" append="true"> <xsl:text disable-output-escaping="yes"></root></xsl:text> </xalan:write>
> Can you think of a sensible use of "disable-output-escaping"?
4 off the top of my head:
a) creating almost-but-not-quite XML like some template languages
<% .... %>
(ASP JSP etc)
As that isn't legal XML, XSLT won't generate it without a bit of from d-o-e.
b) Generating a local subset of a doctype, and entity references, if you _really_ have to.
c) In the MathML specification we use CDATA sections for mathml examples. We don't just "inline" the XML which is the usual advice as we want tight control over things like indentation and use of ' or " around attribute values. If you are telling the user that they can do a="2" or a='2' you don't want the system to write them both out the same way:-) In the normative html version of the spec it's no problem you just value-of the example into a <pre> and it all works, but in the XHTML+MathML version we _also_ want to inline it as XML so you get a side-by-side view of the literal XML and how your browser renders it, we use d-o-e to produce this.
d) If you have quoted html inside your xml as in <foo><![CDATA[ a <br> c <img src= "x.png"> jjj ]]></foo> and you need that html in the output. If you can fix your input not to do that it is good but often you can't (RSS feeds etc) and so d-o-e can be used as a method of last resort (although xslt2 offers alternatives, more on that another day perhaps:-)(
David
________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Chris Loschen closchen@xxxxxxxxxxxxxxxxxx 781-718-3017 (cell)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Preserve HTML formatting , Karl J. Stubsjoen | Thread | Re: [xsl] Preserve HTML formatting , David Carlisle |
Re: [xsl] SelectingSubsetsOfNode-Se, mankar | Date | RE: [xsl] Automatic generation of X, Pieter Reint Siegers |
Month |