Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Boolean true and false as strings >Thread Next - Re: Boolean true and false as strings Re: Boolean true and false as stringsTo: 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 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
