xsl-list
[Top] [All Lists]

[xsl] How an "attribute" used a step under (xsl:if) is getting assigned to its previous node? Is it the way it is expected to work?

2007-06-08 03:33:32
Hello,

I had a requirement of assigning <input type="radio"> with checked and
disabled options on certain condition.

Since, I know I cannot use something like this,

<input type="checkbox" name="something" value="xx">
        <xsl:attribute name="checked">
                <xsl:if test="@SELECTED = 'true'">checked</xsl:if>
                <!-- actually it was xsl:choose -->
        </xsl:attribute>
        <xsl:attribute name="disabled">
                <xsl:if test="$disableFields = 'true'"> disabled
</xsl:if        </xsl:attribute>
</input>

since, the moment checked or disabled attribute is assigned, the input
radio filed is going to take irrespective of whatever value it was
assigned. But what surprised me was the below code, where the
xsl:attribute is moved inside <xsl:if> one step below, do  working fine.


<input type="checkbox" name="something" value="xx">
        <xsl:if test="@SELECTED = 'true'"><xsl:attribute
name="checked">checked</xsl:attribute></xsl:if>
        <xsl:if test="$disableFields = 'true'"><xsl:attribute
name="disabled">disabled</xsl:attribute></xsl:if>
</input>

I was sure the attribute will become part of <if> statement and won't
work, but my stupid(?) instinct forced to give a try and found it
perfectly assigning checked / disabled attribute to the radio field if
the condition met. It this the way it is supposed to work? 


Thanks,
Karl R

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>