Issue (local-constants)

Subject: Issue (local-constants)
From: "Lawton, Scott" <slawton@xxxxxxxxxxxx>
Date: Fri, 6 Nov 1998 14:42:08 -0500
	Issue (local-constants): Should there be a way to define local
constants?
Yes!

And/or: local or global variables.

For example, given this XML as input:
	<item>Fancy</item>
	<item selected="true" value="Dull">Plain</item>

In the first instance, I want to use the contents of the item as both the
visible text and, since there's no value attribute, also use it as the
value:
	Fancy: <newItem value="Fancy"/>

In the second, I want to use the contents as the visible text and the value
attribute as the value:
	Plain: <newItem value="Dull"/>

So, now to my XSL wish list:

<xsl:if test="attribute(value)">
	<xsl:define-constant name="myValue" value="{attribute(value)}"/>
<xsl:else>
	<xsl:define-constant name="myValue" value="{.}"/>
	</xsl:else>
</xsl:if>

Then I could do:
	<newItem value="{constant(myValue)}"/>
Scott
P.S. Did I mention I'd like an xsl:else?  :)


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread