Re: bind select control values to XSD

Iņaki,

If your use case meets the following conditions:

* Labels and values are the same
* The enumeration is defined in the XML schema

then you can load the schema in a separate instance and bind your
itemset to the enumeration.

For example, say you have this in your schema:

   <xs:simpleType name="state">
     <xs:restriction base="xs:string">
       <xs:enumeration value="AL"/>
       <xs:enumeration value="AK"/>
       ...

In the model, do:

   <xforms:instance id="schema-instance" src="schema.xsd"/>

and in the view, within a selection control:

   <xforms:itemset 
nodeset="instance('schema-instance')/xs:simpleType[@name = 
'state']//xs:enumeration">
     <xforms:label ref="@value"/>
     <xforms:value ref="@value"/>
   </xforms:itemset>

We do this in our Government Forms example at:

   http://www.orbeon.com/ops/forms/

-Erik

Iņaki Salinas Bueno wrote:
 > Hi,
 >
 > I want to use the select control to choose between different
 > possibilities. These possibilities are defined in a XSD document. Do I
 > have to rewrite these values in a item list inside the select element or
 > there is a way to use the defined values automatically?
 >
 > I saw the itemset element, but the examples I have seen bound the select
 > control to a list of elements inside the same document, and what I would
 > like is to avoid rewriting what is defined in the loaded XSD document.
 > Is it possible?.
 >
 >
 >
 > Iņaki

-- 
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/

Received on Wednesday, 25 July 2007 15:33:55 UTC