When you use the JAXP API, the base Output URI will normally be the value of the SystemId in the Result object passed to the transform() method. If you don't set the systemId, for example if you do transform(X, new StreamResult(System.out)), then Saxon will use the current directory as the base output URI. It looks as if this is what is happening in the Maven case.
 
You can also set the base output URI directly by casting the Transformer to net.sf.saxon.Controller and using the setBaseOutputURI() method; and you can discover it from your XSLT code (without recompiling anything) using extension functions:
 
<xsl:variable name="controller" select="saxon:getController()"/>
<xsl:value-of select="Controller:getBaseOutputURI($controller)" xmlns:Controller="java:net.sf.saxon.Controller"/>
 
(not tested)
 
I often find that rather than relying on base output URI, it is better to define a stylesheet parameter containing the name of the destination directory, and use this to construct an absolute path name for use in xsl:result-document.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Cosmin Marginean
Sent: 29 March 2008 08:36
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Base output URI

Hello,

I am using Saxon and a stylesheet that takes advantage of xsl:result-document to generate multiple files. As I understand, the relative paths used in the href attribute are relative to the base output uri (as XSL 2.0 specifies).

Now I am running the transformation in two environments (Ant and Maven). I managed to recompile the class net.sf.saxon.event.StandardOutputResolver and in the method resolve(String href, String base) I am printing the base parameter. It seems that this has different values in the 2 different environments: on Ant the value is the same as the output file, while in Maven this value is the current running directory.

Considering that both Maven and Ant are using standard Java transformer API, my question would be: how is it possible, or how can I set a transformer to use as base output uri the output file name (the same as Ant does)? As far as I can tell, Maven is not setting a parameter that Ant is setting (or vice-versa), and maybe if I can figure out which parameter, I can solve the problem.

Thanks in advance,
--
Cosmin Marginean