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

Re: Question about optional element in instance

From: John Boyer <boyerj@ca.ibm.com>
Date: Mon, 19 Feb 2007 17:54:34 -0800
To: m9467470@nirai.ne.jp
Cc: "www-forms@w3.org" <www-forms@w3.org>, www-forms-request@w3.org
Message-ID: <OF90BDABBC.3398F2AB-ON88257288.0009D66B-88257288.000A7E85@ca.ibm.com>

You would of course have some kind of condition that decides whether or 
not the name or sex is needed.

You would use an xforms bind to attach this condition to the relevant 
model item property of the nodes, like this:

<xforms:bind nodeset="name" relevant="some condition"/>

<xforms:bind nodeset="sex" relevant="some other condition"/>

Note that the conditions you set can be based on data nodes in instance 
other than your primary data instance that represents a client.
You can create "temporary variables" in another xforms:instance, and then 
use their content in your conditions, like this:

<xforms:instance id="temp" xmlns="">

<xforms:bind nodeset="name" relevant="instance('temp')/showName = 'true' 

<xforms:bind nodeset="sex" relevant="instance('temp')/showSex = 'true' "/>

If the result of the XPath in the 'relevant' attribute is false, then the 
node(s) indicated by the nodeset attribute is considered to be 
non-relevant by the XForms processor. 

XForms submissions remove non-relevant nodes from data before submission.

John M. Boyer, Ph.D.
STSM: Workplace Forms Architect and Researcher
Co-Chair, W3C Forms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@ca.ibm.com  http://www.ibm.com/software/

Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer

Sent by: www-forms-request@w3.org
02/17/2007 03:29 AM

"www-forms@w3.org" <www-forms@w3.org>

Question about optional element in instance

How can I code the Instance including "optional" element?
ie. the instance is like this.

<xforms:instance id="register">

And the "name" and "sex" elements are optional.
The instance data will send to third party server,
then must pass with the following XML Schema.

<xsd:complexType name="client">
    <xsd:element name="id">...</xsd:element>
    <xsd:element name="name" minOccurs="0">
          <xsd:element name="first">...</xsd:element>
          <xsd:element name="last">...</xsd:element>
    <xsd:element name="sex" minOccurs="0">...</xsd:element>
    <xsd:element name="date">...</xsd:element>

Received on Tuesday, 20 February 2007 01:54:47 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:37:55 UTC