|
Subject: Re: [xsl] attribute vs { } From: "Joerg Heinicke" <joerg.heinicke@xxxxxx> Date: Wed, 27 Mar 2002 08:52:19 +0100 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] attribute vs { }, Ilyasov Jienbay | Thread | [xsl] ASP, XSL, XML QUESTION, Meiyu Lin |
| RE: [xsl] html2xml?, Jarno . Elovirta | Date | RE: [xsl] how to change xml ENCODIN, Jarno . Elovirta |
| Month |