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

Re: Retrieving unknown attribute values

Subject: Re: Retrieving unknown attribute values
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Mon, 14 Oct 2002 14:42:32 -0700
xpath retrieving attribute value
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 14 October 2002 14:28, you wrote:
> I got fixated on attribute value templates

I guess that's a perfectly good thing to get confused about :)  Sorry for 
biting at you so hard.

I'm sure you've figured out the difference between attribute-value-templates 
and the XPath attribute:: axis (abreviated as '@') by now.

<table>
  <tr>
    <!-- you can output the value of an attribute when you know the name -->
    <td><xsl:value-of select="element/@attribute"/></td>
    
    <!-- you can output unknown attributes -->
    <xsl:for-each select="element/@*">
      <td>
        <!-- name of the current attribute -->
        <xsl:value-of select="name()"/>
        <xsl:text>=</xsl:text>
        <!-- value of the current attribute -->
        <xsl:value-of select="."/>
      </td>
    </xsl:for-each>
  </tr>
</table>

Outputting the value of an attribute is different than an attribute value 
template, which is a shortcut to using the <xsl:attribute> tag to create an 
attribute in an element.

<foo>
  <xsl:attribute name="bar">
    <xsl:value-of select="/xyz/baz"/>
  </xsl:attribute>
</foo>

which is the same thing as

<foo bar="{/xyz/baz}"/>

The point is, you only need attribute value templates and xsl:attribute if you 
want to *create* attributes on an element in the *output* document.  If you 
just want to use the value of an attribute in the *source* document, use the 
'element/@attribute' syntax.

- -- 
Peter Davis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9qzpLhDAgUT1yirARAvd0AJ0Xwev3NBDovuUXCK8q0MSJP0pBkQCgg+2T
eu0dYLJ8hv0j6/wttoNX3EM=
=yrBn
-----END PGP SIGNATURE-----


 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.