I have recently upgraded the saxon version from 8.7 to 10.6. The xsl:result-document worked perfectly while i was using saxon version 8.7. Here is what i am facing:
This is my XML format :
<?xml version="1.0" encoding="UTF-8"?>
<Statements>
<title>This is an example document</title>
<Statement>
<Invoice>1234567</Invoice>
<Name>ABC</Name>
</Statement>
<Statement>
<Invoice>9876543</Invoice>
<Name>XYZ</Name>
</Statement>
</Statements>
Here is a piece of my XSLT :
<xsl:template name="EnhanceAccount">
<xsl:result-document href="/data/ebpp/{$FileName}_EnhancedAccountInfo.jr1" method="text">
<xsl:text>InvoiceNumber</xsl:text>
<xsl:text> </xsl:text>
<xsl:for-each select="//Statement">
<xsl:value-of select="InvoiceNumber"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:result-document>
</xsl:template>
And i get the following error :
net.sf.saxon.trans.XPathException: The system identifier of the principal output file is unknown at net.sf.saxon.lib.StandardOutputResolver.resolve(StandardOutputResolver.java:89) at net.sf.saxon.lib.OutputURIResolverWrapper.resolve(OutputURIResolverWrapper.java:58) at net.sf.saxon.expr.instruct.ResultDocument.makeReceiver(ResultDocument.java:528) at net.sf.saxon.expr.instruct.ResultDocument.processLeft(ResultDocument.java:477)
The file gets created and has contents :
Invoicenumber
1234567
After this, it fails. What is the problem here? Please help!
Java code :
File stylesheet = new File(enhanceAccountTemplate);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Templates cachedXSLT = transformerFactory.newTemplates(new StreamSource(stylesheet));
Transformer transformer = cachedXSLT.newTransformer();
transformer.setParameter("FileName", inpfile);
Source src = new StreamSource(inputStream);
Result res = new StreamResult(out);
transformer.transform(src, res);
If running from the command line, make sure that you use the -o option.
If running from the Java API, make sure that the Result
or Destination
object for the transformation result has a non-null SystemId
property.
The href
attribute of xsl:result-document
is interpreted as being relative to the "base output URI" of the transformation, so it needs that property in order to decide where to write the output.
Alternatively, supply an absolute URI in the href
attribute (typically using the file:
URI scheme).