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

Re: element value based on attribute selection

Subject: Re: element value based on attribute selection
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 16 Mar 2001 10:54:11 +0000
userdn
Hi Dave,

> I want to select the value of the <parameter
> name="UserDN">wjohnson</parameter> out of all the
> <parameter> tags.
>
> <xsl:apply-templates select="//parameter???"/>

What is it about that parameter that you want to select on -
presumably its name attribute?  You can get the value of the name
attribute with:

  @name

Test whether it's the same as 'UserDN' with:

  @name = 'UserDN'

and if you put that in a predicate (square brackets) it'll filter the
list of parameter elements accordingly:

  //parameter[@name = 'UserDN']

You might find it better to step down to the parameter elements rather
than use // - otherwise the processor will hunt for parameter elements
all through the document when it doesn't really need to.  Use:

  /parameters/parameter[@name = 'UserDN']

If you have *lots* of parameter elements, and you're picking them out
by their name lots of times, you might find it helpful to define a
key so you can index into them:

<xsl:key name="parameters" match="parameter" use="@name" />

Then you can use:

  key('parameters', 'UserDN')

instead.

[If you wanted to get it by position, use:

  /parameters/parameter[1]

 as it's the first parameter in the list.]

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.