- 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>
Hi,
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="">
<tempData>
<showName>true</showName>
<showSex>false</showSex>
</tempData>
</xforms:instance>
<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.
Cheers,
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
m9467470@nirai.ne.jp
Sent by: www-forms-request@w3.org
02/17/2007 03:29 AM
To
"www-forms@w3.org" <www-forms@w3.org>
cc
Subject
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">
<client>
<id/>
<name>
<first/>
<last/>
<sex/>
<data/>
</client>
</xforms:instance>
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:sequence>
<xsd:element name="id">...</xsd:element>
<xsd:element name="name" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="first">...</xsd:element>
<xsd:element name="last">...</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="sex" minOccurs="0">...</xsd:element>
<xsd:element name="date">...</xsd:element>
</xsd:sequence>
</xsd:complexType>
--
Miyagi
<m9467470@nirai.ne.jp>
Received on Tuesday, 20 February 2007 01:54:47 UTC