Bug #5337
closedcallTemplateReturningValue(null) with PHP does not call the template named xsl:initial-template but rather gives error "java.lang.IllegalArgumentException: Supplied Clark name is null or empty"
100%
Description
The documentation for the Saxon 11 (testing with 11.2 HE now) PHP API and callTemplateReturningValue
says:
Invoke a transformation by calling a named template, and return the result as an
XdmValue
. If the$templateName
argument is null then thexsl:initial-template
is used
However, when I try to pass null
as the method value, Saxon gives an error:
Error found in calltemplateReturningValue
Exception in thread "main" java.lang.IllegalArgumentException: Supplied Clark name is null or empty
at net.sf.saxon.s9api.QName.fromClarkName(Unknown Source)
at net.sf.saxon.option.cpp.Xslt30Processor.callTemplateReturningValue(Unknown Source)
Test code:
<?php
$saxonProc = new Saxon\SaxonProcessor();
$transformer = $saxonProc->newXslt30Processor();
$executable = $transformer->compileFromString("<xsl:stylesheet version='3.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' expand-text='yes'>\n<xsl:template name='xsl:initial-template'><test>{current-dateTime()} : {system-property('xsl:product-name')} {system-property('xsl:product-version')}</test></xsl:template>\n</xsl:stylesheet>");
$root = $executable->callTemplateReturningValue(null);
$node = $root->getHead()->getNodeValue();
print($node);
?>
What works for me to have xsl:initial-template
called is to pass no argument with e.g. $root = $executable->callTemplateReturningValue();
. If that is the intended and only shortcut to have xsl:initial-template
called, then the documentation is misleading.
Updated by O'Neil Delpratt almost 3 years ago
- Status changed from New to In Progress
Firstly, the NULL should be accepted therefore this looks like a bug issue. Secondly, the documentation needs updating to accept zero argument too for both C++ and PHP.
I have reproduced the problem, which does puzzle me because the zero argument does get converted internally to NULL as the argument in this method in C++. My suspicion is we are getting an empty string at some point in the process.
Updated by O'Neil Delpratt almost 3 years ago
- Status changed from In Progress to Resolved
- % Done changed from 0 to 100
Bug found in the PHP extension code. The zend_parse_parameter
function handles the NULL strings as an empty string in C (with possible NUL-bytes). Bug fix applied to check against the length of the string when passing templateName to the C++ API.
Updated by O'Neil Delpratt over 2 years ago
- Status changed from Resolved to Closed
- Fixed in version set to 11.3
Bug fix applied in the SaxonC 11.3 maintenance release.
Please register to edit this issue