|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Preserve HTML formatting when apply-templates in
Hi all,
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 <!ELEMENT root (header, bill+, trailer)> 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. I'm using XSLT 1 and Xalan-J. What I've done is use xalan:write when I process the header like so: <xalan:write file="bills.xml"> <xsl:text disable-output-escaping="true"><root></xsl:text> </xalan:write> As I process each bill, I add to that file like so: <xalan:write file="bills.xml" append="true"> <invoice> <total-records><xsl:value-of select="$total-records"/></total-records> <total-amount><xsl:value-of select="$total-amount"/></total-amount> </invoice> </xalan:write> And finally at the end I close the root element while I'm processing the trailer like so: <xalan:write file="bills.xml" append="true">
<xsl:text disable-output-escaping="yes"></root></xsl:text>
</xalan:write>I end up with a well-formed XML file which I can then read in with the document() function and do the sums I need to do etc. This is working just fine with my current setup (though it leaves a temp file behind, which I haven't dealt with yet), but it strikes me as very ugly, and goes against all I've learned on this list about always outputting complete nodes rather than a start tag in one place and an end tag elsewhere. I haven't been able to come up with a better alternative though. Does anyone have any suggestions or should I just figure it ain't broke so don't fix it? Thanks! PS -- I thank the people who replied to my messages a few days ago -- I sent a reply to the list but I think it never actually made it -- I didn't have access to my normal email account, and I asked Tommie to post it for me, but I never saw it -- no doubt Tommie needs a vacation now and again too! I'll try to post it again as soon as I can. At 11:35 AM 8/6/2004, you wrote: > Can you think of a sensible use of "disable-output-escaping"? Yours, Chris Loschen closchen@xxxxxxxxxxxxxxxxxx 781-718-3017 (cell)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








