This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: sorting on data referenced with document()??
- From: Joerg Heinicke <joerg dot heinicke at gmx dot de>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 18 Sep 2002 09:09:57 +0200
- Subject: Re: [xsl] sorting on data referenced with document()??
- References: <2C9C0B245B4C3A4DBE0DB46519096FE73EAEF6@envchimail1.envestnetpmc.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello Will,
I can only suggest to use Dimitre's solution, which doesn't need
extension functions. If you have problems with it you can ask the list
or Dimitre.
When you want to know how to use extension functions, you can have a
look at http://xml.apache.org/xalan-j/extensionslib.html#ex-nodeset.
It's the nodeset() function of Xalan, which works in the same way like
the EXSLT function, but of course you are more processor dependent then.
Replacing the Xalan namespace with the EXSLT namespace and replacing
xalan:nodeset() with exslt:node-set() should work then. The namespace
for EXSLT node-set() is xmlns:exslt="http://exslt.org/common" as you can
see on http://www.exslt.org/exsl/functions/node-set/index.html. Xalan
2.4 supports EXSLT, so you don't need to download anything from
www.exslt.org.
The problem with your code below:
You have declared xmlns:common="http://exslt.org/common", but you are
using <xsl:for-each select="exsl:node-set($persons)/person">. You have
to change either xmlns:common oder exsl:node-set() in the code. Both
should use the same namespace-prefix. Furthermore you can add a
extension-element-prefixes="exslt" (or exsl or common, the prefix you
use) to the <xsl:stylesheet> to avoid the namepsace declaration on the
output. I think http://www.exslt.org/howto.html can be really helpful.
But for your problem you should really use Dimitre's perfect solution.
Regards,
Joerg
Carter, Will wrote:
hmm...
I figured that I would first try the extension function route, but I can't quite figure out how to get it working. Excuse my ignorance, I am a xslt beginner and I have never added a.
anyway, I tried to first download the function itself:
http://www.exslt.org/exsl/functions/node-set/exsl.node-set.zip
but inside the zip, exsl.node-set.xsl isn't present.????
the only way I could get exsl.node-set.xsl in any manner is to download the all modules zip.
http://www.exslt.org/all-exslt.zip
exsl.node-set.1.xsl and exsl.node-set.2.xsl are in that zip, so I am guessing that those are what I need.
I put these 2 xsl files in the same folder as my two.xsl
so I try to modify my stylesheet:
------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:common="http://exslt.org/common" xmlns="http://www.w3.org/tr/REC-html40" version="1.0">
<xsl:import href="exsl.node-set.1.xsl" />
<xsl:import href="exsl.node-set.2.xsl" />
------------------------------------------------------
I add the variable as instructed (i hope this is right):
------------------------------------------------------
<xsl:variable name="persons">
<xsl:for-each select="people/person">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:copy-of select="*"/>
<xsl:variable name="ownerName" select="@name"/>
<xsl:for-each select="document('xml2.xml')">
<xsl:copy-of select="key('turtleByOwner', $ownerName)"/>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
------------------------------------------------------
and I change the for each in the stylesheet to:
------------------------------------------------------
<xsl:for-each select="exsl:node-set($persons)/person">
------------------------------------------------------
I try to transform with xalan at my command line and I get:
------------------------------------------------------
java org.apache.xalan.xslt.Process -in xml1.xml -xsl two.xsl -out 2.html
file:///C:/xsl/two.xsl; Line 25; Column 57; XSLT Error (javax.xml.transform.Tran
sformerConfigurationException): javax.xml.transform.TransformerException: javax.
xml.transform.TransformerException: Prefix must resolve to a namespace: exslt
------------------------------------------------------
what am I doing wrong?
will
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list