L Duperval wrote:
 <keshlam <at> us.ibm.com> writes:

The normal way to solve this is to generate
each of the output documents in turn, rather than trying to produce them
in parallel. Yes, this may require walking the input document repeatedly,
but XSLT can do so.


So you mean something like <xsl:for-each> to get each id and (possibly) each
value of attr2, then using document() to reopen the document and find the
matching element? Or is there something more efficient?
My input document will contain more than 1000 different ids, so in the approach
I outline that would mean going over the document 1000 times, which seems a lot
to me.

L

If you have access to the Xalan Redirect extension (http://xml.apache.org/xalan-j/extensionslib.html#redirect) you could simply have a template that matches <data> elements and writes out to a new file whose name is based on the value of the @id attribute of the matched <data> element, and then just selectively copies the rest of the matched <data> element you're interested in.

I'm not sure of the technical internals of how Xalan processes the input document, but I believe it would require just one pass of the input document. Of course you will have overhead creating and writing to 1000s of separate output files, but that sounds unavoidable for your requirements.

--
Nathan Nadeau
n...@gleim.com
Software Development
Gleim Publications, Inc.
http://www.gleim.com

Reply via email to