Yes, I think your expectation is reasonable. Oddly the spec doesn't say in so many words that the base URI of the implicit result tree is the base output URI, but it's a reasonable inference from what it does say, and I don't think it says anything to the contrary.

Logged as a bug here: https://saxonica.plan.io/issues/1724

Michael Kay
Saxonica

On 22/03/2013 13:36, Norman Walsh wrote:
Given source.xml:

<doc/>

and style.xml:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:template match="/">
      <x base="{base-uri(/*)}">
        <xsl:copy-of select="/"/>
      </x>
    </xsl:template>
</xsl:stylesheet>

this test program:

package com.xmlcalabash.drivers;

import net.sf.saxon.Configuration;
import net.sf.saxon.lib.CollectionURIResolver;
import net.sf.saxon.lib.OutputURIResolver;
import net.sf.saxon.lib.UnparsedTextURIResolver;
import net.sf.saxon.s9api.DocumentBuilder;
import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.QName;
import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.SaxonApiUncheckedException;
import net.sf.saxon.s9api.ValidationMode;
import net.sf.saxon.s9api.XPathCompiler;
import net.sf.saxon.s9api.XPathExecutable;
import net.sf.saxon.s9api.XPathSelector;
import net.sf.saxon.s9api.XdmAtomicValue;
import net.sf.saxon.s9api.XdmDestination;
import net.sf.saxon.s9api.XdmItem;
import net.sf.saxon.s9api.XdmNode;
import net.sf.saxon.s9api.XsltCompiler;
import net.sf.saxon.s9api.XsltExecutable;
import net.sf.saxon.s9api.XsltTransformer;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;

public class SaxonTest {
    public static void main(String[] args) throws SaxonApiException, IOException, URISyntaxException {
        SaxonTest main = new SaxonTest();
        main.run(args);
    }

    public void run(String[] args) throws SaxonApiException, IOException, URISyntaxException {
        runXSLT();
    }

    protected void runXSLT() throws SaxonApiException {
        Processor processor = new Processor(false);
        Configuration config = processor.getUnderlyingConfiguration();

        DocumentBuilder builder = processor.newDocumentBuilder();
        builder.setDTDValidation(false);
        builder.setLineNumbering(true);

        XdmNode document = builder.build(new File("source.xml"));
        XdmNode stylesheet = builder.build(new File("style.xml"));

        XsltCompiler compiler = processor.newXsltCompiler();
        compiler.setSchemaAware(processor.isSchemaAware());
        XsltExecutable exec = compiler.compile(stylesheet.asSource());
        XsltTransformer transformer = exec.load();

        if (document != null) {
            transformer.setInitialContextNode(document);
        }
        XdmDestination result = new XdmDestination();
        transformer.setDestination(result);

        transformer.setBaseOutputURI("file://tmp/out.xml");

        transformer.setSchemaValidationMode(ValidationMode.DEFAULT);
        transformer.transform();

        XdmNode xformed = result.getXdmNode();
        System.err.println("base: " + xformed.getBaseURI());
    }
}

prints

base:

Should I be surprised by that? I thought setting the output base URI would,
uh, set the, uh, output base URI. :-)

                                        Be seeing you,
                                          norm



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help