Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Boolean true and false as strings

From: "Hoi Wong" <wonghoi@--------.--->
To: NULL
Date: 1/8/2009 2:28:00 AM
I'm using the XSLT scripts in MATLAB. That mean Saxon on XSLT 1.0.

I guess what you said about the nodeset extension means I should made my 
code something like this:

 <xsl:variable name="DEVICE_TYPE_FLAGS">
  <xsl:choose>
   <xsl:when test="$APP_MODEL = 2812">
    <IS_ICD>true</IS_ICD>
    <IS_ATRIAL_ICD>true</IS_ATRIAL_ICD>
   </xsl:when>
   <xsl:otherwise>
    <IS_ICD>true</IS_ICD>
    <IS_ATRIAL_ICD>false</IS_ATRIAL_ICD>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>

But I'm still stuck with strings in the text node of tags like <IS_ICD>. Is 
there a way that I can make the contents inside a tag boolean?

Thanks.

Cheers,
Hoi

"David Carlisle" <david-news@d...> wrote in message 
news:49652F4A.7020601@d......
> 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