Fabrizio Giudici
Fabrizio Giudici

Reputation: 532

Can't use <xsl:evaluate> in Saxon 9.7

I'm running the XML Maven Plugin with this POM fragment:

    <build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xml-maven-plugin</artifactId>
            <version>1.0.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>transform</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <transformationSets>
                    <transformationSet>
                        <dir>${basedir}/target/xml</dir>
                        <stylesheet>${basedir}/target/typesetting/fop/xslt/PhotoBook-fo.xslt</stylesheet>
                    </transformationSet>
                </transformationSets>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>net.sf.saxon</groupId>
                    <artifactId>Saxon-HE</artifactId>
                    <version>9.7.0-15</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

The stylesheet contains a feature, <xsl:evaluate>, that is part of XSLT 3.0, which I understand is supported in Saxon-HE 9.7.0. The stylesheet correctly declares the XSLT version:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:fo="http://www.w3.org/1999/XSL/Format"
            xmlns:xhtml="http://www.w3.org/1999/xhtml">

But processing this fragment:

        <xsl:for-each select="xhtml:tr[1]/xhtml:td">
            <xsl:element name="table-column" namespace="http://www.w3.org/1999/XSL/Format">
                <xsl:attribute name="column-width">
                    <xsl:evaluate select="@width"/>
                </xsl:attribute>
            </xsl:element>
        </xsl:for-each>

I get

[INFO] --- xml-maven-plugin:1.0.1:transform (default) @ birds-portfolio-1 ---
Static error at xsl:evaluate on line 132 column 56 of xhtml5-fo.xslt:  
XTSE0010: Unknown XSLT element: evaluate

What am I missing? Thanks.

Upvotes: 1

Views: 550

Answers (2)

kjhughes
kjhughes

Reputation: 111726

Martin Honnen already helpfully pointed out (+1) that Saxon 9.7 HE doesn't support XSLT 3.0, but I wanted to add another possibility for future readers who may have problems in this area: If Saxon 9.7 EE or PE fails to find a proper license key, it appears to continue to work with reduced functionality, perhaps as it would under HE.

On the one hand, this sort of graceful degradation can be helpful, but on the other hand, it can also be confusing to licensed EE or PE users who don't expect this behavior when failing to properly place a license key file on a new machine setup.

Upvotes: 1

Martin Honnen
Martin Honnen

Reputation: 167716

Saxon 9.7 HE does not support any XSLT 3.0 language feature, you need PE or EE for that (http://saxonica.com/html/documentation/xsl-elements/evaluate.html). The only enhancement you get in 9.7 HE with version="3.0" stylesheets is access to XPath 3.0 expressions (like let) and functions (like serialize or parse-xml).

As for your code, are you sure you need xsl:evaluate? It seems

            <xsl:attribute name="column-width" select="@width"/>

might suffice, unless your width attribute contains an XPath expression you need to evaluate.

I would even replace

    <xsl:for-each select="xhtml:tr[1]/xhtml:td">
        <xsl:element name="table-column" namespace="http://www.w3.org/1999/XSL/Format">
            <xsl:attribute name="column-width">
                <xsl:evaluate select="@width"/>
            </xsl:attribute>
        </xsl:element>
    </xsl:for-each>

with

    <xsl:for-each select="xhtml:tr[1]/xhtml:td">
        <table-column xmlns="http://www.w3.org/1999/XSL/Format" column-width="{@width}"/>
    </xsl:for-each>

Upvotes: 2

Related Questions