https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2022-03-08T11:12:50ZSaxonica Developer CommunitySaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198722022-03-08T11:12:50ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Project</strong> changed from <i>Saxon</i> to <i>SaxonC</i></li><li><strong>Category</strong> set to <i>C++ API</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>In Progress</i></li><li><strong>Assignee</strong> set to <i>O'Neil Delpratt</i></li><li><strong>Priority</strong> changed from <i>Low</i> to <i>Normal</i></li><li><strong>Found in version</strong> set to <i>11.2</i></li></ul><p>Moving this bug issue to the SaxonC Project.</p> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198732022-03-08T11:14:56ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>Do you check for nullptr on the <code>File</code> variable?</p> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198742022-03-08T11:26:04ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>I managed to see the problem is because you have not set a source document or match selection.</p>
<p>The following bit of code will help:</p>
<pre><code class="cpp syntaxhl" data-language="cpp"><span class="k">if</span> <span class="p">(</span><span class="n">File</span> <span class="o">==</span> <span class="nb">nullptr</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="n">xslte</span><span class="o">-></span><span class="n">exceptionOccurred</span><span class="p">())</span> <span class="p">{</span>
<span class="n">cout</span> <span class="o"><<</span> <span class="n">xslte</span><span class="o">-></span><span class="n">getErrorMessage</span><span class="p">()</span> <span class="o"><<</span> <span class="n">endl</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>I get the following error message:</p>
<pre><code>net.sf.saxon.s9api.SaxonApiException : No initial match selection supplied
</code></pre>
<p>So I added the following lines before the <code>transformToString</code> call:</p>
<pre><code class="cpp syntaxhl" data-language="cpp"> <span class="n">xslte</span><span class="o">-></span><span class="n">setInitialMatchSelection</span><span class="p">(</span><span class="n">xmlfile</span><span class="p">);</span>
<span class="n">xslte</span><span class="o">-></span><span class="n">setGlobalContextItem</span><span class="p">(</span><span class="n">xmlfile</span><span class="p">);</span>
</code></pre>
<p>Now getting the following error:</p>
<pre><code>Error in xsl:result-document/@href on line 6 column 44 of file:///location/:
SXRD0002 The system identifier of the principal output file is unknown
In template rule with match="/" on line 4 of file:///location/
invoked by xsl:result-document at file:///location/#6
In template rule with match="/" on line 4 of file:///location/
net.sf.saxon.s9api.SaxonApiException : The system identifier of the principal output file is unknown
</code></pre> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198752022-03-08T11:30:51ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>My last error is because I have loaded stylesheet and xml as strings, but I think you will not see this error</p> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198772022-03-08T11:36:31ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>I confirm I get the output file:</p>
<pre><code class="html syntaxhl" data-language="html"><span class="cp"><?xml version="1.0" encoding="utf-8" standalone="yes"?></span>
<span class="nt"><result></span>
<span class="nt"><value></span>You put a 5<span class="nt"></value></span>
<span class="nt"></result></span>
</code></pre> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198782022-03-08T11:36:42ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>AwaitingInfo</i></li></ul> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198792022-03-08T11:39:19ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>BTW if you run into the error <code>SXRD0002 The system identifier of the principal output file is unknown</code> then you need the following code:</p>
<pre><code class="cpp syntaxhl" data-language="cpp"><span class="n">xslte</span><span class="o">-></span><span class="n">setBaseOutputURI</span><span class="p">(</span><span class="s">"file:///location/"</span><span class="p">);</span>
</code></pre> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198802022-03-08T11:45:56ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>As an alternative to comment #3 it is possible to directly pass the source on the transformToString methodf:</p>
<pre><code class="cpp syntaxhl" data-language="cpp"><span class="n">xslte</span><span class="o">-></span> <span class="n">transformToString</span><span class="p">(</span><span class="n">xmlfile</span><span class="p">);</span>
</code></pre> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198812022-03-08T11:49:07ZMartin Honnenmartin.honnen@gmx.de
<ul></ul><p>It seems still a bit confusing that <code>transformToString</code> works fine without setting <code>xslte->setBaseOutputURI("file:///location/");</code> in code not using <code>xsl:result-document</code> e.g. with</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="nt"><xsl:stylesheet</span> <span class="na">xmlns:xsl=</span><span class="s">"http://www.w3.org/1999/XSL/Transform"</span> <span class="na">version=</span><span class="s">"2.0"</span> <span class="na">expand-text=</span><span class="s">"yes"</span><span class="nt">></span>
<span class="nt"><xsl:output</span> <span class="na">method=</span><span class="s">"xml"</span> <span class="na">encoding=</span><span class="s">"utf-8"</span> <span class="na">standalone=</span><span class="s">"yes"</span> <span class="na">indent=</span><span class="s">"yes"</span><span class="nt">/></span>
<span class="nt"><xsl:template</span> <span class="na">match=</span><span class="s">"/"</span><span class="nt">></span>
<span class="nt"><xsl:message></span>producing sheet<span class="nt"></xsl:message></span>
<span class="nt"><main-result></span>
<span class="nt"><tested-at></span>{current-dateTime()}<span class="nt"></tested-at></span>
<span class="nt"><static-base-uri></span>{static-base-uri()}<span class="nt"></static-base-uri></span>
<span class="nt"></main-result></span>
<span class="c"><!--<xsl:result-document href="output.xml">
<result>
<value>
You put a <xsl:value-of select="/xml/value"/>
</value>
</result>
</xsl:result-document>--></span>
<span class="nt"></xsl:template></span>
<span class="nt"></xsl:stylesheet></span>
</code></pre>
<p>but as soon as I uncomment the use of <code>xsl:result-document</code> with the relative URI SaxonC gives the</p>
<pre><code>SXRD0002 The system identifier of the principal output file is unknown
In template rule with match="/" on line 4 of result-document-test2.xsl
</code></pre>
<p>Perhaps that just needs better documentation/explanation in the documentation that the use of the <code>transformToString</code> together with <code>xsl:result-document</code> requires an explicit setting of the base output URI if relative URIs are used in the XSLT. But it kind of feels that the base output uri might be available from the stylesheet's base URI, as it seems to be if the target is a transformToFile.</p> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198822022-03-08T12:37:39ZIbrahim Usmani
<ul></ul><p>Also using "xsl:result-document" , it outputs the xml files into the same directory as the xslt file that used "result-document" , how to I tell it where to output the files .</p> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198842022-03-08T13:02:35ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>Ibrahim Usmani wrote:</p>
<blockquote>
<p>Also using "xsl:result-document" , it outputs the xml files into the same directory as the xslt file that used "result-document" , how to I tell it where to output the files .</p>
</blockquote>
<p>The result-document will be saved relative to the location set using <code>setBaseOutputURI</code>.</p> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198852022-03-08T13:32:42ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>Martin Honnen wrote:</p>
<blockquote>
<p>It seems still a bit confusing that <code>transformToString</code> works fine without setting <code>xslte->setBaseOutputURI("file:///location/");</code> in code not using <code>xsl:result-document</code> e.g. with</p>
<pre><code class="xml syntaxhl" data-language="xml"><span class="nt"><xsl:stylesheet</span> <span class="na">xmlns:xsl=</span><span class="s">"http://www.w3.org/1999/XSL/Transform"</span> <span class="na">version=</span><span class="s">"2.0"</span> <span class="na">expand-text=</span><span class="s">"yes"</span><span class="nt">></span>
<span class="nt"><xsl:output</span> <span class="na">method=</span><span class="s">"xml"</span> <span class="na">encoding=</span><span class="s">"utf-8"</span> <span class="na">standalone=</span><span class="s">"yes"</span> <span class="na">indent=</span><span class="s">"yes"</span><span class="nt">/></span>
<span class="nt"><xsl:template</span> <span class="na">match=</span><span class="s">"/"</span><span class="nt">></span>
<span class="nt"><xsl:message></span>producing sheet<span class="nt"></xsl:message></span>
<span class="nt"><main-result></span>
<span class="nt"><tested-at></span>{current-dateTime()}<span class="nt"></tested-at></span>
<span class="nt"><static-base-uri></span>{static-base-uri()}<span class="nt"></static-base-uri></span>
<span class="nt"></main-result></span>
<span class="c"><!--<xsl:result-document href="output.xml">
<result>
<value>
You put a <xsl:value-of select="/xml/value"/>
</value>
</result>
</xsl:result-document>--></span>
<span class="nt"></xsl:template></span>
<span class="nt"></xsl:stylesheet></span>
</code></pre>
<p>but as soon as I uncomment the use of <code>xsl:result-document</code> with the relative URI SaxonC gives the</p>
<pre><code>SXRD0002 The system identifier of the principal output file is unknown
In template rule with match="/" on line 4 of result-document-test2.xsl
</code></pre>
<p>Perhaps that just needs better documentation/explanation in the documentation that the use of the <code>transformToString</code> together with <code>xsl:result-document</code> requires an explicit setting of the base output URI if relative URIs are used in the XSLT. But it kind of feels that the base output uri might be available from the stylesheet's base URI, as it seems to be if the target is a transformToFile.</p>
</blockquote>
<p>This is not ideal from a users perspective as they don't have access to the <code>Destination</code> class as in java. I am raising separate bug issue</p> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=198862022-03-08T13:35:22ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-2 priority-2 priority-default closed" href="/issues/5378">Bug #5378</a>: The system identifier of the principal output file is unknown</i> added</li></ul> SaxonC - Bug #5376: Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9https://saxonica.plan.io/issues/5376?journal_id=225432023-01-16T17:33:25ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>AwaitingInfo</i> to <i>Closed</i></li></ul><p>closing this bug as no further action.</p>