W3C home > Mailing lists > Public > www-forms@w3.org > July 2007

Re: bind select control values to XSD

From: Erik Bruchez <ebruchez@orbeon.com>
Date: Wed, 25 Jul 2007 17:33:40 +0200
Message-ID: <46A76D54.4090504@orbeon.com>
To: www-forms <www-forms@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:09 GMT