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

Re: attribute vs { }

Subject: Re: attribute vs { }
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Wed, 27 Mar 2002 08:52:19 +0100
Re:  attribute vs { }
Hello Jian,

both versions are correct, the second (so called "attribute value template")
is obviously shorter and mostly more readable. In some situations you need
the longer version.

Example 1: attribute only when condition is true

<test>
    <xsl:if test="$color != 'black'">
        <xsl:attribute name="color"><xsl:value-of
select="$color"/></xsl:attribute>
    </xsl:if>
</test>

Example 2: attribute value comes from another template

<xsl:template match="/"
    <test>
        <xsl:attribute name="color">
            <xsl:apply-templates select="color"/>
        </xsl:attribute>
    </test>
</xsl:template>

<xsl:template match="color">
    <xsl:value-of select="."/>
</xsl:template>

This is a trivial example, but the second template could be much more
complex or even a recursive template.

So, in the most cases I would use the shorter AVT. Sometimes, if it
necessary, I have to use <xsl:attribute/>.

Regards,

Joerg

> <a>
> <xsl:attribute name="href">
>   <xsl:text>file://</xsl:text>
>   <xsl:value-of select="element">
> </xsl:attribute>
> </a>
>
> and
>
> <a href="file://{element}">
>
> generate the same result with xalan.
> is it allright to use it this way?
>
> jian


 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.