Subject:XQuery equivalent of xsl:result-document Author:Philip Young Date:12 Jun 2007 03:01 PM
As a way to learn more about XQuery I'm converting an XSL 2.0 stylesheet by hand. I've found equivalent constructs for everything except the following:
<xsl:result-document href="{concat('../txt/',$filename, '-test.txt')}">
where the point of the href is to construct a filename for the output of the stylesheet. The $filename variable is taken from the base-uri of the input XML file.
Subject:XQuery equivalent of xsl:result-document Author:Minollo I. Date:12 Jun 2007 03:17 PM
You can't do that directly from XQuery; I can think of two options:
- You create a Java extension function responsible for saving to file a specific XML fragment (that you could serialize to a string using ddtek:serialize() if you are using DataDirect XQuery)
- You make the XQuery return a sequence of XML fragments (rather than a single node), which then you serialize to disk as part of the Java code used to consume the XQuery result
If you indicate a preference for one solution or the other, I can sketch out an example working with DataDirect XQuery to show you how that would work in practice.