Project

Profile

Help

Bug #5376

open

Saxon EE 11.2 "TransformToString()" produces JET RUNTIME with an exit code of 9

Added by Ibrahim Usmani 7 months ago. Updated 7 months ago.

Status:
AwaitingInfo
Priority:
Normal
Category:
C++ API
Start date:
2022-03-08
Due date:
% Done:

0%

Estimated time:
Found in version:
11.2
Fixed in version:
Platforms:

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

Output : enter image description 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

Related to SaxonC - Bug #5378: The system identifier of the principal output file is unknownRejectedO'Neil Delpratt2022-03-08

Actions
Actions #1

Updated by O'Neil Delpratt 7 months 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.

Actions #2

Updated by O'Neil Delpratt 7 months ago

Do you check for nullptr on the File variable?

Actions #3

Updated by O'Neil Delpratt 7 months 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
Actions #4

Updated by O'Neil Delpratt 7 months ago

My last error is because I have loaded stylesheet and xml as strings, but I think you will not see this error

Actions #5

Updated by O'Neil Delpratt 7 months 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>
Actions #6

Updated by O'Neil Delpratt 7 months ago

  • Status changed from In Progress to AwaitingInfo
Actions #7

Updated by O'Neil Delpratt 7 months 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/");
Actions #8

Updated by O'Neil Delpratt 7 months ago

As an alternative to comment #3 it is possible to directly pass the source on the transformToString methodf:

xslte-> transformToString(xmlfile);
Actions #9

Updated by Martin Honnen 7 months 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.

Actions #10

Updated by Ibrahim Usmani 7 months 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 .

Actions #11

Updated by O'Neil Delpratt 7 months 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.

Actions #12

Updated by O'Neil Delpratt 7 months ago

Martin Honnen wrote:

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.

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

Actions #13

Updated by O'Neil Delpratt 7 months ago

  • Related to Bug #5378: The system identifier of the principal output file is unknown added

Please register to edit this issue

Also available in: Atom PDF