xsl-list
[Top] [All Lists]

RE: AW: xsl attribute value

2004-10-27 01:52:54
Thanks Roman and Jarno.

Cheers. Arun


From: "Huditsch Roman" <Roman(_dot_)Huditsch(_at_)lexisnexis(_dot_)at>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: AW: [xsl] xsl attribute value
Date: Wed, 27 Oct 2004 10:27:46 +0200

Hi Arun,

You just have to use "GroupValue/@type" instead of "GroupValue[(_at_)type]" since your definition would just check if the "GroupValue" element has an type attribute and if that's true, output the element's content.

You might use this little stylesheet:

<?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"/>
                        <xsl:text> = </xsl:text>
                     <xsl:value-of select="GroupValue"/>
                        <br/>
                </xsl:for-each>
        </xsl:template>
</xsl:stylesheet>

Hope this helps.

Wbr,
Roman

-----Ursprüngliche Nachricht-----
Von: Arun Sinha [mailto:arunsinha666(_at_)hotmail(_dot_)com]
Gesendet: Mittwoch, 27. Oktober 2004 10:05
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: [xsl] xsl attribute value

Hi

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<?xml-stylesheet type='text/xsl' href='../old/test.xsl' ?>
<Report>
   <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[(_at_)type]" /> =
        <xsl:value-of select="GroupValue" /><br />
    </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>.

Any suggestion?

Thanks.

Arun

_________________________________________________________________
Yantras for power and success. Yantras for peace and joy.
http://www.astroyogi.com/NewMsn/astroshopping/yantra/ Yantras that change your life.


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


_________________________________________________________________
Strike the perfect match on BharatMatrimony.com. http://www.bharatmatrimony.com/cgi-bin/bmclicks1.cgi?74 Join FREE



<Prev in Thread] Current Thread [Next in Thread>