[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] xsl:choose to define conditional attributes?
I'm currently trying to define some conditional processing in order to be able to derive different values for some attributes thanks to <xsl:choose> and <xsl:when>. For instance, using the transformation to generate some HTML, and a <LABEL> tag in the example below, I'd like to do something like the following: <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> generating: <label id="myLabelId" style="MyStyleEmpty">The Label</label> when the content of the element selected is null, and: <label id="myLabelId" style="MyStyleFull">The Label</label> when it's populated with some data. However the above XSL doesn't seem to work. I suspect it is because the XSLT WD states that it should be used for templates only. Ok, but then, how to implement this type of conditional processing (and thus to avoid duplicating the whole definition of the LABEL tag)? Thanks for your help, Olivier. 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
|