W3C home > Mailing lists > Public > www-forms@w3.org > May 2006

XForms support for XML schema xsd:choice

From: Radu Calinescu <Radu.Calinescu@comlab.ox.ac.uk>
Date: Tue, 2 May 2006 16:59:53 +0100
Message-ID: <000601c66e01$73a4a330$357d01a3@comlab.ox.ac.uk>
To: <www-forms@w3.org>

I'm working on an XForms template for XML documents whose associated schemas contain xsd:choice declarations, e.g.,

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  <xsd:element name="root">
        <xsd:element name="foo" type="xsd:string" />
        <xsd:element name="bar" type="xsd:string" />

and finding it difficult to come up with an XForms model/UI combination that supports this use case. 

Although the XForms switch module (http://www.w3.org/TR/xforms/slice9.html#id148519) represents a suitable option for representing the choice in the UI, finding an appropriate model seems more difficult. Simply specifying a model such as:

<xforms:model xmlns:my="http://example.com" 
              xmlns:xforms="http://www.w3.org/2002/xforms" ...>
      <my:foo />
      <my:bar />

ensures that the UI can reference both my:foo and my:bar, but produces invalid XML documents that XForms-capable browsers rightfully reject. For instance, XSmiles (http://www.x-smiles.org/) reports "Invalid content starting with element 'my:bar'. No child element is expected at this point." when submission is attempted.

Notice that the XForms examples provided with the XForms 1.0 recommendation dated 14 March 2006 (http://www.w3.org/TR/xforms/sliceG.html) work around this issue by allowing the xsd:choice element to appear for any number of times in the document, i.e., 

<xsd:sequence minOccurs="0" maxOccurs="unbounded">

which makes an instance document such as the one suggested above valid, but does not address my specific use case.

IBM's XForms Generator (http://www.alphaworks.ibm.com/tech/xfg) comes with a number of "choice"-related samples that pair XML schemas with xsd:choice declarations and XML instance documents similar to the one presented above, and therefore suffer from the same limitation.

I would be grateful for any comments that might clarify this issue.

Received on Tuesday, 2 May 2006 18:54:33 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:17 UTC