Project

Profile

Help

Bug #5337

closed

callTemplateReturningValue(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"

Added by Martin Honnen almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
PHP API
Start date:
2022-02-18
Due date:
% Done:

100%

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

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 the xsl: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.

Please register to edit this issue

Also available in: Atom PDF