Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Boolean true and false as strings

From: David Carlisle <david-news@---------.-----.--.-->
To: NULL
Date: 1/7/2009 10:40:00 PM
Hoi Wong wrote:
> I accidentially hit send before finishing...
> 
> =============================
> 
> As I'm trying to do conditional variable assignment (see the post below), I
> have to use
> 
> <xsl:variable name="someName">
>     <xsl:value-of select="true()"/>
> </xsl:variable>
> 
> instead of
> 
> <xsl:variable name="someName" select="true()"/>
> 
> but apparently value-of select converts my variable to string instead of
> boolean, and that leaves a dangerous trap in my code that people who follow 
> up might try to test the string and always return TRUE.
> 
> Is there any other ways to assign boolean values using <xsl:variable> 
> without putting "select" at the same line.
> 
> Thanks.
> 
> Cheers,
> Hoi 
> 
> 

you coul duse copy-of instead of value-of which avoids value-of making a 
text node, but in xslt1, it won't help as if you use xsl:variable 
without a select attribute the result is a result tree fragment, which 
isn't what you want.


If you are using xslt2  you can use if()... then... else ... within the 
select expression.

If you are using xslt1 and have access to a x:noe-set() extesnion 
function (almost all xslt 1 engines support this) then normally the 
thing to do is not define 40 global variables but rather just define one 
structured variable.

so don't use $a1, .....  $a40, use
$a/a1, ...$a/a40

where the global variable $a holds an in-memory XML fragment that you 
construct that contains all the data.

David

-- 
http://dpcarlisle.blogspot.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