Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing attribute value in XSLT 1

Status
Not open for further replies.

woogoo

Programmer
Feb 14, 2004
247
GB
Hi all, I have an XML file similar in layout to the sample below and I would like to print the value of the elements id parameter.

Code:
<System>
<Unit>
    <Name id='TZ-1'>Value goes here...</Name>
    <Desc id='TZ-2'>Value goes here...</Desc>
    ...
</Unit>
<Plant>
    <Rating id='PI-1'>Value goes here...</Rating>
    ...
</Plant>
</System>

I've raked around the Internet and can't find anything; either that or it's so obvious I'm missing it. I'm using XSLT to transform the the XML to XHTML using templates.

If I use:

<xsl:value-of select="Name[@id]"/>

Inside my match="Unit" template I get 'Value goes here...' as the output! Not what I'd expected.

Can anyone please point me in the right direction here please.

--
Woogoo
 
<xsl:value-of select="Name[@id]"/>
[tt]<xsl:value-of select="Name[red]/@id[/red]"/>[/tt]
 
Hi tsuji, it works! So I've given you (IMHO) a well deserved star, thank you.

--
Woogoo

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top