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

Re: using document in xsl:key match...

Subject: Re: using document in xsl:key match...
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 10 May 2004 14:50:41 -0400
xsl key match
John-Mark,

At 02:27 PM 5/10/2004, you wrote:
I am trying to use xsl:key to index a set of elements from another document.
When I try to do:
<xsl:key match="document('ed.xml')/root/sup" use="@name"/>
I get:
XPath error : Invalid expression
//document('ed.xml')/root/sup
           ^
compilation error: file tb.xml line 7 element key
xsl:key : XPath pattern compilation failed '//document('ed.xml')/root/sup'

It appears that a // is being prepended to my XPath query, which is causing
it to fail.  Is this suppose to be a valid construct (using document in
an xsl:key match term)?  Or is this a bug in the library?

It's not a valid construct. The match attribute on xsl:key must follow the same restrictions on match patterns in general.


Just declare the key with a match as if it were a match on a template (match="sup" would do, or match="root/sup"), and then when you need to retrieve the node you want, change context to the ed.xml document. The key function will then work within that context. (I'd give an example but since you haven't said what you're doing with the key, it might not apply. Ask again if you need to.)

I hope that helps,
Wendell

After additional reading of: http://www.w3.org/TR/xslt#NT-Pattern
It appears this construct is not allowed.  Is this correct?

Yes, it is: not allowed.



====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

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.