[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Conditional variable assignment

Subject: RE: Conditional variable assignment
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Thu, 19 Oct 2000 12:07:19 +0100
conditional variable
> <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>
> </xsl:variable>

Try
<xsl:variable name="style" 
select="string((@style_override | $default_style)[last()])"/>

This relies on the fact that the @style_override attribute will be later in
document order than the @default_style attribute.

Mike Kay

> -----Original Message-----
> From: Melvyn Rosengarden [mailto:melrose@xxxxxxxxxxxxxxxx]
> Sent: 18 October 2000 01:30
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: Conditional variable assignment
> 
> 
> 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
> 


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.