Subject: RE: choose to define conditional attributes? From: Mike Brown <mbrown@xxxxxxxxxxxxx> Date: Thu, 30 Sep 1999 15:02:44 -0600 |
> <label> > <xsl:attribute name="id">myLabelId</xsl:attribute> > <xsl:choose> > <xsl:when test=". = ''"> > <xsl:attribute name="style">MyStyleEmpty</xsl:attribute> > </xsl:when> > <xsl:otherwise> > <xsl:attribute name="style">MyStyleFull</xsl:attribute> > </xsl:otherwise> > </xsl:choose> > The Label > </label> http://www.w3.org/TR/xslt#creating-attributes says, "Instantiating an xsl:attribute element adds an attribute node to the containing result element node". It's not terribly clear, but the "containing" node is the <xsl:attribute>'s parent, which is <xsl:when> in your example. You want the parent to be a result element, i.e. a literal result element like <label> or an <xsl:element> instruction. Furthermore, <xsl:choose>...</xsl:choose> gets replaced by characters. If there were some non-whitespace characters in the <xsl:when> or <xsl:otherwise>, you'd end up with those being inserted right before " The Label" in the content of <label>. You really want the characters to end up inside your <xsl:attribute>. Try it this way instead: <label> <xsl:attribute name="id">myLabelId</xsl:attribute> <xsl:attribute name="style"> <xsl:choose> <xsl:when test=". = ''"> <xsl:value-of select="'MyStyleEmpty'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="'MyStyleFull'"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> The Label </label> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
xsl:choose to define conditional at, oberthier | Thread | Using CDATA but still "<" is ins, Rolande Kendal |
xsl:choose to define conditional at, oberthier | Date | Using CDATA but still "<" is ins, Rolande Kendal |
Month |