Multiple documents as streams in Saxon (using document() function)

43 views
Skip to first unread message

B.

unread,
Jun 25, 2008, 10:54:22 AM6/25/08
to XSLT
We're invoking a certain XSLT transformation from Java using Saxon
library. The XSLT is a file but all XMLs are streams generated
dynamically.
Currently we're simply setting the source, and params, the destination
on the transformer object. It works fine.

The thing is, now we need to also provide an additional external XML
document to be used by the XSL transformation. It's also a stream, not
available as a file. We'd like to use the document() function in XSL
but AFAIK it supports only hardcoded XML files (either relative or
full path). I'm wondering if there is some hack around it allowing to
use a stream initialized in Java instead.

Hope this is enough information for you guys to try to help. If
anything else is needed, just let me know.

Regards,
B.

B.

unread,
Jun 26, 2008, 10:30:44 AM6/26/08
to XSLT
One idea was to hack into the resolver and upon encountering a certain
file name just return a stream fetched elsewhere. As it turns out it
could be done for XSD lookup but cannot be done for the XML document
referenced in document() function:

public void setURIResolver(URIResolver resolver)
Set the URIResolver to be used during stylesheet compilation. This
URIResolver, despite its name, is not used for resolving relative URIs
against a base URI; it is used for dereferencing an absolute URI
(after resolution) to return a Source representing the location where
a stylesheet module can be found.
This URIResolver is used to dereference the URIs appearing in
xsl:import, xsl:include, and xsl:import-schema declarations. It is not
used at run-time for resolving requests to the document() or similar
functions.
Parameters:
resolver - the URIResolver to be used during stylesheet
compilation.

So, I'm still stuck.
B.
Reply all
Reply to author
Forward
0 new messages