Project

Profile

Help

Bug #6357

closed

Exception: Source object is not of type (String, XdmValue or XdmValue[]). Line number: -1

Added by O'Neil Delpratt 10 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Category:
SaxonC API
Start date:
2024-02-21
Due date:
% Done:

100%

Estimated time:
Applies to branch:
Fix Committed on Branch:
12
Fixed in Maintenance Release:
Found in version:
12.4.2
Fixed in version:
12.5
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:

Description

The following PHP script fails with the exception below:

        $transformer = self::$saxonProc->newXslt30Processor();
        $source = "<?xml version='1.0'?>" .
            "                <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" .
            "                xmlns:xs='http://www.w3.org/2001/XMLSchema'" .
            "                version='3.0'>" .
            "                <xsl:output method='text' item-separator='~~'/>" .
            "                <xsl:template match='.'>" .
            "                   <xsl:param name='a' as='xs:double'/>" .
            "                   <xsl:param name='b' as='xs:float'/>" .
            "                   <xsl:sequence select='., \$a + \$b'/>" .
            "                </xsl:template>" .
            "                </xsl:stylesheet>";
        $executable = $transformer->compileFromString($source);
        $executable->setProperty("!omit-xml-declaration", "yes");
        $executable->setResultAsRawValue(True);
        $executable->setInitialTemplateParameters(array("a" => self::$saxonProc->createAtomicValue(12), "b" => self::$saxonProc->createAtomicValue(5)));
        $executable->setInitialMatchSelection(self::$saxonProc->createAtomicValue(16));
        $sw = $executable->applyTemplatesReturningString();

Exception:

Exception: Source object is not of type (String, XdmValue or XdmValue[]). Line number: -1

It looks like the setInitialMatchSelection method is not correctly passing the XdmAtomicValue. After more investigation the selection is being passed as null in the Java code.

Actions #1

Updated by O'Neil Delpratt 10 months ago

  • Status changed from New to In Progress

This is a classic case of where we are not assigning XdmAtomicValue to a variable and therefore not increasing the refCount. This results in the object getting garbage collected before use in the processor.

Actions #2

Updated by O'Neil Delpratt 10 months ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

I have increased the refCount of the XdmValue used in the setInitialMatchSelection method. The GC in PHP will get rid of the object after the applyTemplatesReturningString is called. This is really a partial fix for SaxonC 12.

Actions #3

Updated by O'Neil Delpratt 6 months ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 12.5

Bug fix applied in the Saxon 12.5 Maintenance release.

Actions #4

Updated by Community Admin 6 months ago

  • Fix Committed on Branch 12 added

Please register to edit this issue

Also available in: Atom PDF