RE: Optional Instance Element

Here are some quick answers:

    -----Original Message-----
    From: Borgrink, Susan [mailto:sborgrink@progeny.net] 
    Sent: Tuesday, November 04, 2003 11:28 AM
    To: www-forms@w3.org
    Subject: Optional Instance Element


    I have a question about the instance element.  The specification says
that the instance element is optional.  
    Does this mean that it is always optional or optional only when it would
be unnecessary anyway.
The instance element is optional in so-called "lazy author" mode, where the
a flat instance of name/value pairs is inferred from the UI controls bound
to the model, as long as all of the UI controls refer to nodes just by a
single name (ref="foo", but not ref="foo/bar").
The lack of an instance triggers this special, but important, processing
mode.

	    The example in the XForms test suite that tests the optional
instance element is as follows:

	    <html xmlns="http://www.w3.org/2002/06/xhtml2"
		   xmlns:xforms="http://www.w3.org/2002/xforms"
	       xmlns:ev="http://www.w3.org/2001/xml-events"
		   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		   xml:lang="en">
		  <head>
			 <title>Allow a model with no instance</title>
			    <xforms:model id="m_001">
			    </xforms:model>
		      </head>
		     <body>
			<xforms:group>
			   <xforms:label>No "instance" element
supplied.</xforms:label>   no ref in here.
			</xforms:group>
		     </body>
		  </html>

	 It does not reference any instance data anyway so it makes sense
not to have the instance element.
It's not really a good example, just a test to make sure that the XForms
processor does not declare this an error.
A good example would be one using lazy author mode, which is what the
feature is form.

	 In every other example in the test suite if a Form control has a
ref or a bind to a node in the instance data, 
       the instance element always seems to be present with at least an
empty node for that reference.   
       Here is a simple example where the input control has "ref a" and a is
in the instance data.

In the normal (non-lazy mode), which is in place whenever there is an
instance element, the instance element must have exactly one child.
(That child may have any number of child elements.)  
Importantly, if there are form controls that refer to non-existent nodes in
the instance, those form controls are treated as if
they had been declared relevant="false()".  
		<html xmlns="http://www.w3.org/2002/06/xhtml2"
		xmlns:xforms="http://www.w3.org/2002/xforms"
		    xmlns:ev="http://www.w3.org/2001/xml-events"
		    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		    xmlns:foreign="http://example.com/2003/foreign"
		    xml:lang="en">
		  <head>
		     <title>Test case for assertion 2.</title>
		       <xforms:model id="m_001"
foreign:test="foreignAttribute">
			 <xforms:instance id="i_001" xmlns=""
foreign:test="foreignAttribute">
			  <r>
			     <a></a>
			    <b/>
			  </r>
		     </xforms:instance>
		    <xforms:submission id="s1"
action="http://example.com/2003/foreignTest" />
		      </xforms:model>
		  </head>
		 <body>
		    <xforms:input ref="a">
		   <xforms:label>Input:</xforms:label>
		    </xforms:input>
	     </body>
		  </html>

	    So my question is as follows:  Would the above XForm example
containing  <xforms:input ref="a"> 
          still be valid if it was written without the instance element in
the model or does it need the instance element with at least an empty "a"
node to be acceptable?
So, according to the rule of no-instance->lazy author and no-node->not
relevant, the above example without an instance would still be valid, and an
instance of the following form would be inferred from the <xforms:input
ref="a">:
  <xforms:instance
xmlns=""><instanceData><a/></instanceData></xforms:instance>

	    If the answer to the above question is that the instance element
still does not have to be present, then how would the following example
match up?

	    <xforms:model id="m_001">
	       <xforms:submission id="s1"
action="http://example.com/2003/foreignTest" />
	    </xforms:model>

		<xforms:input ref="a[@att1='help']">
		<xforms:label>Input1:</xforms:label>
		    </xforms:input>
		<xforms:input ref="a[@att2='me']">
		 <xforms:label>Input2:</xforms:label>
		 </xforms:input>

The lack of an instance would trigger lazy author mode.  There are no
plain-looking refs, so there would be no nodes under the instance data, so
the inferred instance would be
   <xforms:instance xmlns="><instanceData/></xforms:instance>
Now, the second rule kicks in, and the two refs on the two inputs would
refer to non-existent nodes in the instance, and would be treated as
irrelevant, and not displayed.

	    Would these two inputs both reference the same node that had two
attributes 
          (<instance> <r> <a att1='help' att2='me'/> </r> </instance>) or
would they reference two different
          nodes each with one of the attributes (<instance> <r> <a
att1='help' /> <a  att2='me'/> </r> </instance>) ?

The lazy author instance inference engine does not try to solve such
problems.  You'd have to have something like this to make use of lazy author
mode:
	    <xforms:model id="m_001">
	       <xforms:submission id="s1"
action="http://example.com/2003/foreignTest" />
	    </xforms:model>

		<xforms:input ref="a-help">
		<xforms:label>Input1:</xforms:label>
		    </xforms:input>
		<xforms:input ref="a-me">
		 <xforms:label>Input2:</xforms:label>
		 </xforms:input>

In the case where the instance is explicitly supplied, either of the two
         <instance> <r xmlns=""> <a att1='help' att2='me'/> </r> </instance>
         <instance> <r xmlns=""> <a att1='help' /> <a  att2='me'/> </r>
</instance>
would result in a form where both inputs would display, but in one case they
would be bound to the same node and in the other to different nodes.

Received on Tuesday, 4 November 2003 14:53:19 UTC