Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Conditional variable assignment

From: "Hoi Wong" <wonghoi@--------.--->
To: NULL
Date: 1/7/2009 2:17:00 AM
FAQ#27 basically suggest breaking down <xsl:variable name="XX" 
select="someXpath"> into <xsl:variable name="XX"><xsl:value-of 
select="someXpath"></xsl:variable> and that'll make my code clumsy.

Even worse, I just found that <xsl:value-of> converts the results to 
strings, which screws up boolean variables.

Is there any way that I can still define a variable conditionally yet the 
result doesn't have to be converted to strings?

Thanks.

Cheers,
Hoi





"Martin Honnen" <mahotrash@y...> wrote in message 
news:4963454d$0$30233$9b4e6d93@n......
> Hoi Wong wrote:
>> I was trying to conditionally define a bunch of global variable but turns 
>> out that I'm stuck with FAQ#27 in this page:
>> http://www.dpawson.co.uk/xsl/sect2/N8090.html
>>
>> What it says is that I have to select the value inside variable 
>> definition, instead of assigning different values to a variable depending 
>> on the conditions.
>>
>> However, I have 40 variables that needs to be defined base on 3 logical 
>> cases (<xsl:choose>). Doing so will make my XSLT scripts unreadable and 
>> there's a lot of typing. Is there any other way round?
>
> I am not completely sure I understand your problem. If you want to define 
> variable values based on certain conditions and you want to avoid 
> repeating code then consider to put the code into a function (XSLT/XPath 
> 2.0) or a template (XSLT/XPath 1.0 and 2.0).
>
>
> -- 
>
> Martin Honnen
> http://JavaScript.FAQTs.com/ 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent