Re: [xsl] taking a literal or a attribute value

Subject: Re: [xsl] taking a literal or a attribute value
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 26 May 2003 13:23:00 -0400

This hardly counts as "nice"...

<element attribute="{concat(@width, substring('100%',1,boolean(@width)*4))}">

but it should work (untested though).

If you wanted to parameterize '100%' you could use

concat(@width, substring($value,1,boolean(@width)*string-length($value)))

If you do this, write a comment to explain it for the next poor soul who has to reach into your code. :->

Me, I'm going off line for a few days ... and there may be more elegant solutions.


At 11:01 AM 5/26/2003, you wrote:
i would like to set a xml element attribute to the value of
an currently processed element or a literal.

i could do it for sure like

<xsl:when test="@width"><xsl:value-of select="@width" /></xsl:when> <xsl:othrwise>100%</xsl:othrwise>

i just wonder if there are any nice xpaths ways to make
this more simple..

___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_ "Thus I make my own use of the telegraph, without consulting the directors, like the sparrows, which I perceive use it extensively for a perch." -- Thoreau

XSL-List info and archive:

Current Thread