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

RE: Creating a variable based on another element value

Subject: RE: Creating a variable based on another element value
From: Jarno.Elovirta@xxxxxxxxx
Date: Wed, 8 Oct 2003 17:11:00 +0300
xsl creating a variable
Hi,

> Given this xm ldoc:
> <ve pos=1"><entrydata><text>mena</text></entrydata></ve>
> <ve pos=2"><entrydata><text>proc</text></entrydata></ve>
> <ve pos=3"><entrydata><text>security</text></entrydata></ve>
> <ve pos=4"><entrydata><text>protocal</text></entrydata></ve>
> <ve pos=5"><entrydata><text>network</text></entrydata></ve>
> <ve pos=6"><entrydata><text>lol</text></entrydata></ve>
> 
> I would like to store the position number of the <ve> tag (in 
> a variable 
> called "secpos") which contains entrydata[0]/text='Security. 

This will always return an empty node-set, you probably mean entrydata[1] or something?

> I have got the 
> ve which does this but i dont know how to extract the 
> position attribute and 
> create a variable at the same time? This is what i have got 
> at the moment:
> 
> <xsl:variable name="secpos" 
> select="viewentry[entrydata/text='Security']" />
> 
> but i need it to store the position attribute of the ve which 
> has text 
> containing security? Apologies if this question is a bit easy 
> to others but 
> i didnt know where to look..

How about

  <xsl:variable name="secpos" select="ve[entrydata/text = 'security']/@pos"/>

You didn't specify what the current context is for the evaluation, so I assume the parent element of the ve elements. Note that XPath string comparisions are not case-insensitive.

Cheers,

Jarno - Velvet Acid Christ: Fun With Knives

 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.