|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








