0

I'm trying to start using EXSLT.

Here's my base XSL.

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

    <xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes"/>
    <xsl:variable name="main" select="/data"/>

    <xsl:template match="/data">

        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        HTML STARTS
            <br/>
            <xsl:variable name="metadata" select="document('metadata.xml')"/>
            Straight Value of<br/>
            <xsl:value-of select="$metadata"/>          
            Node-set value of <br/>
            <xsl:value-of select="exsl:node-set($metadata)/email"/>


            <xsl:for-each select="$metadata/Data">
                <xsl:variable name="node" select="."/>
                <xsl:value-of select="$node"/>
                Test<br/>


            </xsl:for-each>

        </html>
    </xsl:template>
</xsl:stylesheet>

I've downloaded the common module from the EXSLT website. (http://www.exslt.org/exsl/index.html)

The structure of this module is:

base.css
exsl.xsl
/functions/node-set/base.css
/functions/node-set/exsl.node-set.xml
/functions/object-type/base.css
/functions/object-type/exsl.object-type.xml
/elements/document/base.css
/elements/document/exsl.document.xml
(+ some htmls in each folder). 

I extract this and place it in the same directory as my base XSL, so that exsl.xsl and my base xsl are in the same folder.

The exsl.xsl sayss

<?xml version="1.0" encoding="utf-8"?>
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/exsl" version="1.1" extension-element-prefixes="exsl" exsl:doc="http://www.exslt.org/exsl">
   <import href="node-set/exsl.node-set.xsl"/>
   <import href="object-type/exsl.object-type.xsl"/>
</stylesheet>

Now this seems wrong in itself as it's not pointing to the functions folder first. However, even if I add function:

   <import href="functions/node-set/exsl.node-set.xsl"/>
   <import href="functions/object-type/exsl.object-type.xsl"/>

I get a 'Local file not found' error on XMLSpy.

Any idea how I get this started?

dwjohnston
  • 11,163
  • 32
  • 99
  • 194
  • Ok, so part of the problem is that those are _xml_ in the folder, and _xsl_ it's trying to import... – dwjohnston Oct 07 '13 at 22:30
  • What XSLT processor are you using? Yes ... it makes a difference. – Kevin Brown Oct 07 '13 at 22:45
  • I'm using XMLSpy - but otherwise Internet Explorer 8. – dwjohnston Oct 07 '13 at 22:55
  • >I'm using XMLSpy, that gives no indication of what XSLT processor you are using. – Kevin Brown Oct 07 '13 at 22:56
  • How would I find out? Looking at this page, http://en.wikipedia.org/wiki/Category:XSLT_processors I assumed that XMLSpy had its own processor. – dwjohnston Oct 07 '13 at 23:04
  • XMLSpy like any other *good* XSLT debugger allows you to set what XSLT engine you wish to use ... because you should use the same XSLT engine in client-side development as you use in deployment. It could be Xalan, Saxon, XSLCompiledtransform, MSXML, .... and the list goes on – Kevin Brown Oct 07 '13 at 23:07
  • Copied from their marketing lit: The XSL Options dialog allows you to customize the behavior of the XSLT editor. XMLSpy includes the award-winning, standards-conformant Altova XSLT processor for performing XSLT 1.0 and schema-aware XSLT 2.0 transformations, and it also provides built-in support for the MSXML XSLT engine. An open XSLT architecture allows the use of any other external XSLT processor, including Apache Xalan, Saxon, or XT. This enables you to build a powerful Web site that fully utilizes XSLT 1.0 or 2.0. – Kevin Brown Oct 07 '13 at 23:09
  • Ok - sweet that's helpful. It's selected to Built-in XSLT engine - there's also a note 'Important: The built in XSLT engine is always used for debugging'. Not sure what that means for clicking the 'browser' view in XMLSpy - does count as debugging? – dwjohnston Oct 07 '13 at 23:11
  • You should use the XSLT engine that you plan to use in your deployment to do proper testing. And I do not use XMLSpy that often but it's likely that means the built-in XSLT engine is used for profiling your solution. If it is always used for debugging, it would give me another reason not to use it. – Kevin Brown Oct 07 '13 at 23:15
  • So back to the original question reworded, "What XSLT engine are you going to use for your production deployment?" – Kevin Brown Oct 07 '13 at 23:22
  • So given that I'm going to be using Internet Explorer to be running this webapp - I would?... As it stands, it looks like I'm going to use the MSXSL, which appears to be working fine. – dwjohnston Oct 07 '13 at 23:25
  • ^Mainly I've been having trouble understanding how XSLT extensions work. - XSLT1.0 doesn't work for what I want to do - I need to use the node-set function. I understand that both EXSLT and MSXSL both implement this function, so the question was, how do I use these? – dwjohnston Oct 07 '13 at 23:28
  • You have now answered your own question. Reference the namespace is all. They are included. You should need nothing else like trying to integrate the XSLs into your own. – Kevin Brown Oct 07 '13 at 23:42
  • If you have `` then there is no need to use the `exsl:node-set` function at all as the `document` function gives you a node-set. You only need the `exsl:node-set` function if you create a result tree fragment and then want to use XPath on nodes in the result tree fragment, in that case `exsl:node-set` helps converting the result tree fragment to a node-set on which XPath can be applied. – Martin Honnen Oct 08 '13 at 09:00

1 Answers1

0

As noted above:

Reference the EXSLT namespace is all. They are included.

If you have <xsl:variable name="metadata" select="document('metadata.xml')"/> then there is no need to use the exsl:node-set function at all as the document function gives you a node-set.

Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265