Page 1 of 1

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

Posted: Thu Apr 06, 2017 12:49 pm
by Martin Honnen
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

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

Posted: Thu Apr 06, 2017 3:36 pm
by adrian
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

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

Posted: Fri Apr 07, 2017 3:10 pm
by Martin Honnen
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
.

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

Posted: Fri Apr 14, 2017 2:37 pm
by adrian
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

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

Posted: Fri Jun 07, 2019 5:43 pm
by geddie2001
Hi,

I have this in my stylesheet:

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"
    version="3.0">
    <xsl:template name="main">
        
        <xsl:call-template name="{http://www.w3.org/1999/XSL/Transform}initial-template"/>
        
    </xsl:template>
</xsl:stylesheet>
However, I'm getting the following error:

Code: Select all

XTSE0020: Both the prefix {{http} and the local part {//www.w3.org/1999/XSL/Transfor...} are invalid
I am using Saxon-PE 9.6.0.7

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

Posted: Mon Jun 10, 2019 1:04 pm
by Martin Honnen
The thread so far was about using the oXygen GUI to use a transformation scenario and run Saxon with XSLT 3 without a primary source but to start with that particular named template the XSLT 3.0 spec defines.



It is not clear how your post relates to that as you have presented XSLT code using

Code: Select all

<xsl:call-template name="{http://www.w3.org/1999/XSL/Transform}initial-template"/>
which doesn't make any sense as your stylesheet does contain any such template you want to call.

Furthermore the first Saxon release to implement the final XSLT 3 standard is Saxon 9.8.

I can't tell whether 9.6 supports enhanced QNames in the name attribute of call-template but the syntax for that in code would be (https://www.w3.org/TR/xpath-30/#prod-xp ... lifiedName)

Code: Select all

<xsl:call-template name="Q{http://www.w3.org/1999/XSL/Transform}initial-template"/>
And of course using

Code: Select all

<xsl:call-template name="xsl:initial-template"/>
would do as well, as long as 9.6 supports that XSLT 3 feature.