Re: [xsl] Retrieving unknown attribute values

Subject: Re: [xsl] Retrieving unknown attribute values
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Mon, 14 Oct 2002 14:42:32 -0700
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.

    <!-- 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/@*">
        <!-- name of the current attribute -->
        <xsl:value-of select="name()"/>
        <!-- value of the current attribute -->
        <xsl:value-of select="."/>

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.

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

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
Version: GnuPG v1.0.7 (GNU/Linux)


 XSL-List info and archive:

Current Thread