checkbox from a "string" type

Today's problem:
 
My xml file has some "flag" elements which are ostensibly boolean.
 
They can appear in my data like this:
 
 
<flag/>   (false)
<flag></flag>  (false)
<flag>1</flag> (true)
 
 
and I assume they could show up as
 
<flag>true</flag>
<flag>false</flag>
 
but I haven't seen them spelled out in the data so far.
 
In my Xform presentation of this I would like these elements to show
up as a checkbox or some other user interface that won't let the users
wander from the true/false nature of the thing.
 
To get the checkbox, I'm using a small second instance
containing just the set of flags and defining them as type="xs:boolean".
At event xforms-ready I am attempting to initialize the second instance
elements to the appropriate values.  Then when I submit I attempt
to move that information back into the main data instance.
 
My problem is that I'm having a real struggle trying to get the second
instance elements to initialize in a reliable way.  Something
simple like
 
 <xf:bind nodeset="instance('flagSet')/flag" id="flag" type="xs:boolean"/>
...
<xf:action ev:event="xforms-ready">
         <xf:setvalue bind="flag" value="boolean-from-string(/top/flag)"/>
</xf:action>
 
gives me errors about an undefined function. 
 
Am I going about this in a reasonable way?  What should I be doing?
 
Chris

 

Received on Wednesday, 20 May 2009 19:02:34 UTC