How to use a template named xsl:initial-template with XSLT 3.0 and oXygen 19

Here should go questions about transforming XML with XSLT and FOP.
Martin Honnen
Posts: 26

How to use a template named xsl:initial-template with XSLT 3.0 and oXygen 19

Thu Apr 06, 2017 12:49 pm

oXygen 19 now supports Saxon 9.7 EE or PE to run XSLT 3.0 transformations, a new feature in XSLT 3.0 is the predefined template name xsl:initial-template for a named template e.g.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:math="http://www.w3.org/2005/xpath-functions/math"
   exclude-result-prefixes="xs math"
   expand-text="yes"
   version="3.0">
   
   <xsl:param name="seq" as="xs:string*" select="'c', 'a', 'b', 'z'"/>
   
   <xsl:template name="xsl:initial-template">
      This is a test {sort($seq)}
   </xsl:template>
   
</xsl:stylesheet>


When you run Saxon from the command line the -it option suffices to select that template as the initially executed starting point of the transformation. How can I achieve that in oXygen 19 with Saxon 9.7 EE selected as the transformer? I can set the initial template in the options to that name but when I try to run the transformation I get the errors

Code: Select all

System ID: C:\Users\User\Somepath\test2017040601.xsl
Scenario: test2017040601
XSL file: C:\Users\User\Somepath\test2017040601.xsl
Engine name: Saxon-EE 9.7.0.15
Severity: error
Description: The requested initial template xsl:initial-template does not exist

System ID: C:\Users\User\Somepath\test2017040601.xsl
Scenario: test2017040601
XSL file: C:\Users\User\Somepath\test2017040601.xsl
Engine name: Saxon-EE 9.7.0.15
Severity: fatal
Description: XTDE0040: The requested initial template xsl:initial-template does not exist
URL: http://www.w3.org/TR/xslt20/#err-XTDE0040
adrian
Posts: 2326

Re: How to use a template named xsl:initial-template with XSLT 3.0 and oXygen 19

Thu Apr 06, 2017 3:36 pm

Hello,

I'm afraid v19.0 does not yet support the default initial template that Saxon 9.7 supports.
The problem is Saxon 9.7 does not seem to work if you explicitly specify the default initial template name, which is mandatory in Oxygen. So it won't work with -it:"xsl:initial-template", it fails with "Template xsl:initial-template does not exist (or is not public)". This is why it doesn't work like that in Oxygen either.
I have logged an issue for this. We will notify this thread when it is implemented/supported.

Until then I propose using the following workaround:
- declare a template (e.g. main) that calls the default initial template:

Code: Select all

    <xsl:template name="main">
        <xsl:call-template name="xsl:initial-template"/>
    </xsl:template>

- configure the initial template in the advanced options from Oxygen to that name ("main").
Outside of Oxygen you can simply rely on the "xsl:initial-template".

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Martin Honnen
Posts: 26

Re: How to use a template named xsl:initial-template with XSLT 3.0 and oXygen 19

Fri Apr 07, 2017 3:10 pm

I managed to get it to work with oXygen by specifying the template name in the form

Code: Select all

{http://www.w3.org/1999/XSL/Transform}initial-template
instead of

Code: Select all

xsl:initial-template
.
adrian
Posts: 2326

Re: How to use a template named xsl:initial-template with XSLT 3.0 and oXygen 19

Fri Apr 14, 2017 2:37 pm

Hi,

Good find. I can confirm your workaround. I have tested and it works in both Oxygen 19.0 and Oxygen 18.x + Saxon-EE 9.7 External Add-on.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “XSLT and FOP”

Who is online

Users browsing this forum: Bing [Bot] and 0 guests