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

RE: xsl attribute value

Subject: RE: xsl attribute value
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Wed, 27 Oct 2004 11:25:36 +0300
xsl attribute value
Hi,

>    <Group>
>        <GroupValue type='PO'>PO0005</GroupValue>
>    </Group>
>    <Group>
>        <GroupValue type='SUPPLIER'>Supplier One</GroupValue>
>    </Group>
> </Report>
>
> In the above XML exmple I am trying to generate the following
> output :-
>
> PO = PO0005
> SUPPLIER = Supplier One
>
> I am using the following xslt.
>
> <?xml version="1.0" ?>
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="/Report">
>     <xsl:for-each select="Group">
>         <xsl:value-of select="GroupValue[@type]" /> =

"GroupValue" selects a node-set of "GroupValue" child element nodes, "[@type]"
filters out those nodes that do not have a "type" attribute, and xsl:value-of
will extract the string value of the first node in document order.

>         <xsl:value-of select="GroupValue" /><br />

Here, again, xsl:value-of will give you the string value of the first
GroupValue element.

>     </xsl:for-each>
> </xsl:template>
>
> </xsl:stylesheet>
>
> This is generating the following output :-
>
> PO0005 = PO0005
> Supplier One = Supplier One
>
> Basically it is not printing the vlue of attribute 'type'.
>
>
> When I chnge the XSLT as follows :-
>
> <xsl:template match="/Report">
>     <xsl:for-each select="Group/GroupValue">
>         <xsl:value-of select="@type" /> =
>         <xsl:value-of select="." /><br />
>     </xsl:for-each>
> </xsl:template>
>
> Then it works.
>
> But my requirement is to print attribute value if the
> current node is <Group>.

I don't understand, how would the output differ from the output your solution
above already generates with the source you showed us?

Cheers,

Jarno - Mark Kavanagh: One Hour DJ Mix

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.