Free XSLT 2.0 library with EXSLT support?

Here should go questions about transforming XML with XSLT and FOP.
Roelfie
Posts: 6
Joined: Wed Dec 12, 2012 1:13 pm

Free XSLT 2.0 library with EXSLT support?

Post by Roelfie »

I have a version 2.0 XSLT. I want to pass in a map (key-value pairs) as a template parameter, and came across this article:

http://www.devsumo.com/technotes/2013/0 ... arameters/

The article is about XSLT 1.0 but I guess it should also work with 2.0 (I couldn't find any information about improved support for map parameters in XSLT 2.0 anyway).

Now I'm stuck looking for a (free / open source) XSLT 2.0 java library, that supports the following (copied from above article):

Code: Select all


            <xsl:for-each select="exslt:node-set($entries)//mapEntry">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="value"/></td>
</tr>
</xsl:for-each>
I don't want to use Saxon-PE/EE because they're not free. Saxon-HE does not offer support for exslt. According to the following

http://stackoverflow.com/questions/5897 ... n-saxon-he
http://www.xmlplease.com/elements-functions

(to mention a few) EXSLT extensions should be available in Saxon-B 9.1.0.3. However, when I configure Saxon-B 9.1.0.3 as the JAXP XSLT transformer in oXygen (javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl in the oXygen preferences copied the jar to the oxygen/lib folder; and chose the JAXP transformer in my transformation scenario), my XSLT does not validate, and complains about
Engine name: JAXP
Severity: fatal
Description: Cannot find a matching 1-argument function named {http://exslt.org/common}node-set(). There is no Saxon extension function with the local name node-set
Start location: 33:77
URL: http://www.w3.org/TR/xpath20/#ERRXPST0017
What's going on?
  • Didn't I configure the Saxon-B library correctly in oXygen?
  • Does Saxon-B 9.1.0.3 support {http://exslt.org/common}node-set(), or doesn't it?
  • Any other suggestions for making the above exslt extension work with a free 2.0 engine?
  • Or am I doomed to go back using XSLT 1.0 and use something like Xalan to make the example work?
Roelfie
Posts: 6
Joined: Wed Dec 12, 2012 1:13 pm

Re: Free XSLT 2.0 library with EXSLT support?

Post by Roelfie »

I don't need this anymore. I solved things differently.

Instead of passing a map as a parameter to the stylesheet, I have the stylesheet read an external XML file (containing my map) as follows:

Code: Select all


<xsl:param name="labels">
<xsl:copy-of select="document('labels.xml')"/>
</xsl:param>
where labels.xml looks like this:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="key1">value1</entry>
<entry key="key2">value2</entry>
</properties>
and this function does the lookup for me:

Code: Select all


    <xsl:function name="via:label">
<xsl:param name="inputkey"/>
<xsl:variable name="label"><xsl:value-of select="$labels//entry[@key=$inputkey]/text()"/></xsl:variable>
<xsl:choose>
<xsl:when test="$label!=''">
<xsl:value-of select="$label"/>
</xsl:when>
<xsl:otherwise>
{<xsl:value-of select="$inputkey"/>}
</xsl:otherwise>
</xsl:choose>
</xsl:function>
Works in XSLT 2.0 with Saxon-HE 9.5.1.2.
Post Reply