[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to use document() of doc() function with copy

Subject: Re: How to use document() of doc() function with copy idiom, or how to acc
From: Abel Braaksma Online <abel.online@xxxxxxxxx>
Date: Tue, 25 Jul 2006 21:37:44 +0200
input hint
Hi David,

Thanks for looking into this. I understand that the expression is expensive, though I didn't realize it before you drew attention to it. The reason I want to do this, is because I am using XSLT as export wrapper. The application gives all kinds of information about the object to be exported, even user defined ones. These are not mapped inside the loaded document and should be added using some kind of convention.

Because getting this information and using it requires quite some understanding of our product, I was creating a utility xslt that transforms all this information (zero, one, or more input files, one or more output files, target types, copies, pass-through information for the next step: xsl-fo, filters, and user defined info) in on type of object, containing a set of documents. In my example, there was only one document loaded, but in fact, there can be many, and they all appear in a structure like this (which goes into the xslt utility stylesheet to be used as an imported stylesheet as a variable called $webitor-input):

<!-- getting the following data from command line arguments and the input format, so that the wheel need not be reinvented each time -->
<doc input-filename="xxx.xml" output-hint="yyy.csv" last-change="yymmdd" created="yymmdd">

All because there's total freedom of a set of documents that go in and are of a certain type (or not, we have a general type), and the set of documents that go out. This way we can combine addresses with titles with localized country names, with selected text blocks and paragraphs and markup code, all from our frontend data application. The output can be pdf (with one more step for xsl-fo of course), html, csv, tab, xml, streamserve tbl format, doc1 internal format, wordml, oo doc xml format, oo calc xml format etc.

If there is a less resource eating way of tackling this, I would gladly hear about it, but I am not sure your suggestion holds here. Yet, it will run only on user command, and with not too many resources (1000 records would be much, but can happen).

Abel Braaksma
Nuntia B.V.

David Carlisle wrote:

I replaced it with <xsl:copy-of select="doc(xxx)" /> and now it works.

It works, but it's very expensive on memory. You end up with two copies of your input document in memory, the first one, loaded with doc() and a second new document stored in $documents that has a different structure and _copies_ of all the nodes of the first.

It's not clear why you need to wrap your source document in a new <doc>
element before applying templates, if instead you wrnt

<xsl:variable name="document" select="document($input-file)"/>

then $document would be the (original) document node.
You would then just generate the <doc> element on output,

<xsl:template name="main" match="/">
<input-filename><xsl:value-of select="." /></input-filename>
<xsl:apply-templates select="$document/*" mode="copy" />

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.