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

Re: accessing attributes

Subject: Re: accessing attributes
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 09 Sep 2008 18:19:04 -0400
Re:  accessing attributes
Tom,

At 03:34 PM 9/9/2008, you wrote:
Wendell,
Thanks for the prompt, clear reply. Advice like that so helps with
learning.
I take your point about using a xsl:key. I had tried this
<xsl:key name="fields" match="/*/fmp:METADATA/fmp:FIELD" use="position()"/>

However I now understand that position() function won't work as I expected.

Can you give me some similar clues how to get around this?

As you've discovered, the job of position() isn't to determine a node's position in the source tree. It returns the position of a node within its processing context, what's called the "current node list", which is relative to the particular traversal in which a node is retrieved (which can be different). So it's not useful here, since a key declaration doesn't have any processing context as such.


The usual solution to this problem is to determine your position directly by examining the tree. So:

<xsl:key name="fields" match="/*/fmp:METADATA/fmp:FIELD" use="count(preceding-sibling::fmp:FIELD) + 1"/>

will allow you to retrieve the fourth fmp:FIELD element with the key value '4', the ninth with value '9', etc.

In other words, by its "position".

Cheers,
Wendell



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