[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Loading an external file of index

Subject: Re: Loading an external file of index
From: Pierre Attar <patt@xxxxxxxxx>
Date: Thu, 22 Jun 2000 23:32:14 +0200
external file xslt
Jeni,

I've tried your sample using xalan and it complains.

The code is :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:variable name="sharedDoc">document('../shared/shared.xml')</xsl:variable>
<xsl:key name="mysetofkeys" match="KEYBASE/KEY" use="@NAME"/>


....

<xsl:template match="KEYREF">
<xsl:variable name="keyrefname" select="@LINKEND" />
<xsl:for-each select="$sharedDoc">
<b><xsl:value-of select="key('mysetofkeys', $keyrefname)/ACRONYM" /></b>
</xsl:for-each>
</xsl:template>


...

</xsl:stylesheet>


And the error is, at runtime transformation :


=============================
Transforming...
XPATH: Can not convert #UNKNOWN to a NodeList!
Xalan: was not successful.
XSLProcessor: done

Any idea ?

Regards,

Pierre

At 12:29 22/06/2000 +0100, you wrote:
Unfortunately, I know from struggling with some fairly recent questions
that this doesn't work.  You can't use the document() function within the
'match' attribute of xsl:key.  Instead, define the key as if the input
document was the one with the keys in, at the top level of the stylesheet:

<xsl:key name="mysetofkeys" match="/keybase/key" use="@name" />

Then, when you want to use it, put the key() function within an
xsl:for-each that has the document that holds the keys as its 'select'
attribute:

<xsl:template match="keyref">
<xsl:variable name="keyrefname" select="@name" />
<xsl:for-each select="document('../shared/shared.xml')">
<b><xsl:value-of select="key('mysetofkeys', $keyrefname)/ACRONYM" /></b>
</xsl:for-each>
</xsl:template>


This is kind of explained in the XSLT Recommendation at
http://www.w3.org/TR/xslt#function-key, right at the end of that section.


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.