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

RE: Getting and using an xml attribute

Subject: RE: Getting and using an xml attribute
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 30 Nov 2007 15:51:36 -0000
RE:  Getting and using an xml attribute
You can select the attribute as

//inactiveTab[@name='Email']/@ID

and you can save it in a variable (if you need to) as

<xsl:variable name="id" select="//inactiveTab[@name='Email']"/>

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Aaron Johnson [mailto:artpunx@xxxxxxxxx] 
> Sent: 30 November 2007 15:23
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Getting and using an xml attribute
> 
> Hello...
> 
> Is it possible to select an attribute, take its value and 
> re-use it elsewhere?
> 
> I have some xml...the ID attribute value changes depending on 
> user, but the name attribute always stays the same. So it may 
> look like this....
> 
> <navigation>
> 	<inactiveTab ID="1" name="Home"/>
>         <inactiveTab ID="2" name="Away"/>
>         <inactiveTab ID="3" name="Foo"/>
>         <inactiveTab ID="4" name="Bar"/> </navigation>
> 
> ....or this....
> 
> <navigation>
> 	<inactiveTab ID="100" name="Home"/>
>         <inactiveTab ID="200" name="Away"/>
>         <inactiveTab ID="300" name="Foo"/>
>         <inactiveTab ID="400" name="Bar"/> </navigation>
> 
> Behind the scenes, urls are created automatically that 
> incorporate the ID....
> 
> ...inactiveTabID=1&uP_sparam=mode&mode=view
> ...inactiveTabID=2&uP_sparam=mode&mode=view
> ...inactiveTabID=3&uP_sparam=mode&mode=view
> 
> ....or this....
> 
> ...inactiveTabID=100&uP_sparam=mode&mode=view
> ...inactiveTabID=200&uP_sparam=mode&mode=view
> ...inactiveTabID=300&uP_sparam=mode&mode=view
> 
> ...they contain the ID, but never the name.
> 
> I need to create a "manual" url, but because the ID value 
> changes, I need a way to "find out" what the ID value is 
> first. I thought by finding the element that contains 
> name='Email, like this...
> 
> //inactiveTab[@name='Email']
> 
> ...I could then take the value of any ID attribute and then 
> append it to the end of my manual URL(...as a variable?). I 
> would then always
> (hopefully!) know that the manual url would look like the 
> automatically generated URL.
> 
> So, my question is, how do I capture the value of the ID 
> attribute of any element containing name="Home" and make it 
> into something "re-usable"?
> 
> Does this make sense? I hope I am not over complicating things!!!
> 
> Thanks for your help...
> 
> Aaron

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.