BaseURITest test = new BaseURITest();
test.run();
}
public void run() throws SaxonApiException {
Processor processor = new Processor(false);
Configuration config = processor.getUnderlyingConfiguration();
String textStyle = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'\n"
+ " version='2.0'>\n"
+ "\n"
+ "<xsl:output method='xml' encoding='utf-8' indent='no'\n"
+ " omit-xml-declaration='yes'/>\n"
+ "\n"
+ "<xsl:preserve-space elements='*'/>\n"
+ "\n"
+ "<xsl:template match='/'>\n"
+ " <xsl:apply-templates/>\n"
+ "</xsl:template>\n"
+ "\n"
+ "<xsl:template match='*'>\n"
+ " <xsl:copy>\n"
+ " <xsl:copy-of select='@*'/>\n"
+ " <xsl:apply-templates/>\n"
+ " </xsl:copy>\n"
+ "</xsl:template>\n"
+ "\n"
+ "<xsl:template match='comment()|processing-instruction()|text()'>\n"
+ " <xsl:copy/>\n"
+ "</xsl:template>\n"
+ "\n"
+ "</xsl:stylesheet>\n";
String textXML = "<doc xml:base='foo/'><para xml:base='bar/'/></doc>";
SAXSource stylesheet = new SAXSource(new InputSource(new StringReader(textStyle)));
XsltCompiler compiler = processor.newXsltCompiler();
XsltExecutable exec = compiler.compile(stylesheet);
XsltTransformer transformer = exec.load();
//transformer.getUnderlyingController().setBaseOutputURI("http://example.com/");
// No resolver, there isn't one here.
DocumentBuilder builder = processor.newDocumentBuilder();
SAXSource document = new SAXSource(new InputSource(new StringReader(textXML)));
XdmNode context = builder.build(document);
transformer.setInitialContextNode(context);
XdmDestination result = new XdmDestination();
transformer.setDestination(result);