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

Re: Using key with XPath and use value?

Subject: Re: Using key with XPath and use value?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 15 Jan 2003 12:31:17 -0500
key xpath
Steven,

You can enhance your key by including in its value some kind of identifier of the b element, to disambiguate d elements not only by their @pub, but by their b ancestors, as in:

<xsl:key name="pubsBySubheadandB" match="d"
   use="concat(generate-id(ancestor::b), '-', @pub)"/>

With this trick, you want to be careful, since the expression in @use now returns a string not a node-set. But since you never have more than one @pub per b element (attributes being what they are), you're okay here.

Naturally when you call the key you need to perform the same concatenation.

Cheers,
Wendell

At 12:14 PM 1/15/2003, you wrote:
If <xsl:key> is defined at the top-level of a document (i.e., globally), can
you get to values based on the XPath as well as the key value?

For example, I'm attempting to output subheads based on the attribute value
of an element. I have element <b> which can have several element <d>
descendants. <d> has a 'pub' attribute which is used to determine the
subhead I need and all matching pub attributes are grouped for output under
the appropriate subhead. <b>, however, can occur any number of times in a
document. If I define a key as such:

<xsl:key name="pubsBySubhead" match="d" use="@pub"/>

can I get to the values for only the specific <b> for which I'm processing?
I seem to be getting everything indexed in the key for each matching @pub,
which is basically all the matches thoughout the whole document.


======================================================================
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
======================================================================


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.