|
Subject: Conditional variable assignment From: "Melvyn Rosengarden" <melrose@xxxxxxxxxxxxxxxx> Date: Tue, 17 Oct 2000 20:30:26 -0400 |
The root node of my document has a style attribute which serves as the
default for the entire XML document. Nested subordinate elements MAY have an
attribute that overrides the document default as shown in the snipet below.
<root_element default_style="style1">
<child>
<grandchild style_override="style5"/>
</child>
</root>
As you might guess the logic of my XSLT says if the grandchild has an
override use its value otherwise use the default. Once I know which value
to use I need to construct an <xsl:choose> to know what to do next.
I created a top-level (global) variable to capture the default style so it
will be available when I instantiate the grand child node
<xsl:variable name="default_style" select="root_element/@default_style />
Now I THINK I would like to create ONE variable to use in the xsl:choose
construct.....BUT I can't quite get it right.
CONCEPTUALLY I want to say:
<xsl:variable name="style"
<xsl:if test="@style_override">
style = @style_override
</xsl:if>
<xsl:if test="not(@style_override)">
style =$default_style
</xsl:if>
<!-- Now with the variable "style" set -->
<xsl:choose>
<xsl:when text="$style=style1">
....call template1....
</xsl:when>
<xsl:when text="$style=style2">
....call template2....
</xsl:when>
Any help would be greatly appreciated....Thanks
"You already have zero privacy -- get over it !!
Melvyn Rosengarden
melrose@xxxxxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: How to choose XSLT engine (WAS:, G. Ken Holman | Thread | Re: Conditional variable assignment, Steve Muench |
| Re: SUMMARY: Re: Sorting on a varia, John E. Simpson | Date | Adding or modifying by path, Hans Gerwitz |
| Month |