tags:

views:

251

answers:

3

I am trying to use an exslt extension in one of my transformations. I got an example off this site about how to concatenate xml files into one.

I have implemented the namespace and the element prefix correctly, but every time I try and run it from my command line I recieve the following error...

Cannot find a matching 1-argument function named {http://exslt.org/common}node-set() in variable step-concat (filename and line number are in here blah blah blah)

I have no idea what is going wrong as I am quite new to this stuff. My xsl file is

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">

<!-- STEP Files -->
<xsl:variable name="step-output">
    <xsl:for-each select="/index/file">
        <xsl:copy-of select="document(.)" />
    </xsl:for-each>
</xsl:variable>

<!-- STEP Files as one -->
<xsl:variable name="step-concat" select="exsl:node-set($step-output)" />

<!-- Root Template -->
<xsl:template match="/">
    <xsl:element name="foo">
        <xsl:apply-templates select="$step-concat/foo"/>
    </xsl:element>
</xsl:template>

<xsl:template match="foo">
    <xsl:element name="text">
        <xsl:value-of select="bar"/>
    </xsl:element>
</xsl:template>

What am I doing wrong? I have tried downloading the module from exslt.org, but it doesn't make any sense to me at all...

A: 

The exslt.org stuff only works when you register/add the extensions to your XSLT engine. Since you don't mention anything about your platform, it's kind of hard to help you out.

Lucero
Thanks for the reply, I'm on Win XP using Saxonhe 9.2.0.3 (Java version) from the command line. This is very confusing stuff...
Designermonkey
+1  A: 

Saxon HE does not provide any built-in extension function, unlike Saxon PE.

However, you can write and register your own extension functions at the Processor, so you could easily implement exsl:node-set: http://www.saxonica.com/documentation/extensibility/integratedfunctions.html

Another alternative is to use Saxon B 9.1

Max Toro
I've switched to Xalan-J, it might not be xsl2 compatiable, but it does have the extensions.Thanks for your help everyone!
Designermonkey
+1  A: 

That's an XSLT 1.0 stylesheet. XSLT 2.0 makes many of the EXSLT extension functions unnecessary, such as "exsl:node-set()". You could convert this to an XSLT 2.0 stylesheet that does the same thing by changing the "version" in the first line to 2.0, and replace "exsl:node-set($step-output)" with just "$step-output". Of course XSLT 2.0 would require Saxon.

pdxleif