Bug #6357
closedException: Source object is not of type (String, XdmValue or XdmValue[]). Line number: -1
100%
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.
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.
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.
Updated by O'Neil Delpratt 5 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.
Please register to edit this issue