Bug #5376
closed

Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9
0%
Description
So I've been using "XsltExecutable::TransformtoString()" , it works with most of my xslts , but i have an xslt that produces a JET RUNTIME ERROR and returns with an exit code of 9.
I've searched what "exit code 9" means , and it said that it means that the OS is killing the program because I dont have enough memory ?????
This works with "TransformFiletoFile()" and all my other xslts but not this one.
This Xslt is using "xsl:result document" to output multiple files. Ive tried setting "BaseOutputURI()" but it still doesn't work . here is some more info :
Xml size :
192,957 KB
Xslt size (The One That Fails) : 24 KB
Code :
SaxonProcessor* processor = new SaxonProcessor(false);
Xslt30Processor* xslt = processor->newXslt30Processor();
XdmNode* xmlfile = processor->parseXmlFromFile( Xml File );
XsltExecutable* xslte = xslt->compileFromFile( Xslt File );
std::string File = xslte->transformToString(); // Fails here
Example xml file :
<xml>
<value>5</value>
</xml>
Example xslt file :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" encoding="utf-8" standalone="yes" indent="yes"/>
<xsl:template match="/">
<xsl:message>producing sheet</xsl:message>
<xsl:result-document href="output.xml">
<result>
<value>You put a <xsl:value-of select="/xml/value"/></value>
</result>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
Related issues
Updated by O'Neil Delpratt over 1 year ago
- Project changed from Saxon to SaxonC
- Category set to C++ API
- Status changed from New to In Progress
- Assignee set to O'Neil Delpratt
- Priority changed from Low to Normal
- Found in version set to 11.2
Moving this bug issue to the SaxonC Project.
Updated by O'Neil Delpratt over 1 year ago
Do you check for nullptr on the File
variable?
Updated by O'Neil Delpratt over 1 year ago
I managed to see the problem is because you have not set a source document or match selection.
The following bit of code will help:
if (File == nullptr) {
if (xslte->exceptionOccurred()) {
cout << xslte->getErrorMessage() << endl;
}
}
I get the following error message:
net.sf.saxon.s9api.SaxonApiException : No initial match selection supplied
So I added the following lines before the transformToString
call:
xslte->setInitialMatchSelection(xmlfile);
xslte->setGlobalContextItem(xmlfile);
Now getting the following error:
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
Updated by O'Neil Delpratt over 1 year ago
My last error is because I have loaded stylesheet and xml as strings, but I think you will not see this error
Updated by O'Neil Delpratt over 1 year ago
I confirm I get the output file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<result>
<value>You put a 5</value>
</result>
Updated by O'Neil Delpratt over 1 year ago
- Status changed from In Progress to AwaitingInfo
Updated by O'Neil Delpratt over 1 year ago
BTW if you run into the error SXRD0002 The system identifier of the principal output file is unknown
then you need the following code:
xslte->setBaseOutputURI("file:///location/");
Updated by O'Neil Delpratt over 1 year ago
As an alternative to comment #3 it is possible to directly pass the source on the transformToString methodf:
xslte-> transformToString(xmlfile);
Updated by Martin Honnen over 1 year ago
It seems still a bit confusing that transformToString
works fine without setting xslte->setBaseOutputURI("file:///location/");
in code not using xsl:result-document
e.g. with
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" expand-text="yes">
<xsl:output method="xml" encoding="utf-8" standalone="yes" indent="yes"/>
<xsl:template match="/">
<xsl:message>producing sheet</xsl:message>
<main-result>
<tested-at>{current-dateTime()}</tested-at>
<static-base-uri>{static-base-uri()}</static-base-uri>
</main-result>
<!--<xsl:result-document href="output.xml">
<result>
<value>
You put a <xsl:value-of select="/xml/value"/>
</value>
</result>
</xsl:result-document>-->
</xsl:template>
</xsl:stylesheet>
but as soon as I uncomment the use of xsl:result-document
with the relative URI SaxonC gives the
SXRD0002 The system identifier of the principal output file is unknown
In template rule with match="/" on line 4 of result-document-test2.xsl
Perhaps that just needs better documentation/explanation in the documentation that the use of the transformToString
together with xsl:result-document
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.
Updated by Ibrahim Usmani over 1 year ago
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 .
Updated by O'Neil Delpratt over 1 year ago
Ibrahim Usmani wrote:
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 .
The result-document will be saved relative to the location set using setBaseOutputURI
.
Updated by O'Neil Delpratt over 1 year ago
Martin Honnen wrote:
It seems still a bit confusing that
transformToString
works fine without settingxslte->setBaseOutputURI("file:///location/");
in code not usingxsl:result-document
e.g. with<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" expand-text="yes"> <xsl:output method="xml" encoding="utf-8" standalone="yes" indent="yes"/> <xsl:template match="/"> <xsl:message>producing sheet</xsl:message> <main-result> <tested-at>{current-dateTime()}</tested-at> <static-base-uri>{static-base-uri()}</static-base-uri> </main-result> <!--<xsl:result-document href="output.xml"> <result> <value> You put a <xsl:value-of select="/xml/value"/> </value> </result> </xsl:result-document>--> </xsl:template> </xsl:stylesheet>
but as soon as I uncomment the use of
xsl:result-document
with the relative URI SaxonC gives theSXRD0002 The system identifier of the principal output file is unknown In template rule with match="/" on line 4 of result-document-test2.xsl
Perhaps that just needs better documentation/explanation in the documentation that the use of the
transformToString
together withxsl:result-document
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.
This is not ideal from a users perspective as they don't have access to the Destination
class as in java. I am raising separate bug issue
Updated by O'Neil Delpratt over 1 year ago
- Related to Bug #5378: The system identifier of the principal output file is unknown added
Updated by O'Neil Delpratt 9 months ago
- Status changed from AwaitingInfo to Closed
closing this bug as no further action.
Please register to edit this issue