Project

Profile

Help

How to call template xsl:initial-template with Python and SaxonC 11.1

Added by Martin Honnen about 2 years ago

The API documentation of Python and SaxonC 11.1 suggests with https://www.saxonica.com/saxon-c/doc11/html/saxonc.html#PyXsltExecutable that the functions call_template_returning_X for the template name allow the use of None to "call the initial-template" (which I understand, means the XSLT 3 predefined xsl:initial-template).

However, my attempts to do so fail:

import saxonc

with saxonc.PySaxonProcessor(license=False) as proc:
         print("Test SaxonC on Python")
         print(proc.version)
         xslt30proc = proc.new_xslt30_processor()
         xslt30Executable = xslt30proc.compile_stylesheet(stylesheet_text = '''
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="3.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="#all"
  expand-text="yes">

  <xsl:output method="html" indent="yes" html-version="5"/>

  <xsl:template match="/" name="xsl:initial-template">
    <html>
      <head>
        <title>Test</title>
      </head>
      <body>
        <h1>Test</h1>
        <ol>
          <xsl:iterate select="1 to 5">
            <li>Item {.}</li>
          </xsl:iterate>
        </ol>
      </body>
    </html>
    <xsl:comment>Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}</xsl:comment>
  </xsl:template>

</xsl:stylesheet>
        
         ''')
         
         result = xslt30Executable.call_template_returning_string(None)
         
         print(result)

outputs

Test SaxonC on Python
SaxonC-HE 11.1 from Saxonica
None

Is the documentation wrong or the Cython code needs to pass NULL instead of NONE to the C++ API to allow calling `xsl:initial-template?


Replies (1)

RE: How to call template xsl:initial-template with Python and SaxonC 11.1 - Added by O'Neil Delpratt about 2 years ago

Thanks for reporting this issue. Bug issue created #5274.

    (1-1/1)

    Please register to reply