RE: XForms: how to disable the use of the XML Schema?

Hi Olivier,
 
[Cross-posting to both lists since you asked the question on both lists :)]
 
Please take a look at the wiki entry TutorialNillable:
 
  <http://www.xforms-wiki.com/bin/view/Main/TutorialNillable>
 
You'll see that the bit you need to add is the second step:
 
  <http://www.xforms-wiki.com/bin/view/Main/TutorialNillable#Using_xsi_nil>
 

As to the integer problem, there was a bug in formsPlayer whereby the
display was not always updated correctly to reflect the model's state. The
bug would show itself by updating the error state on the next refresh, so if
this is the cause of your problem you would see your control displayed as
invalid after you edit some other data.
 
This bug was fixed in recent versions of 1.4. Installation is now via CAB
files, and you can ensure that you and your users are upgraded automatically
by changing the object tag in your documents to this:
 
  <object id="formsPlayer" width="0" height="0"
   classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58"
 
codebase="http://www.formsplayer.com/download/download/cab/formsPlayer.cab#V
ersion=1,4,1,1002"
  >
    ...
  </object>
 
If a user has a version less than the one in @codebase they will be asked if
they want to upgrade to the latest version.
 
Version 1.4 includes a number of changes to comply with XForms 1.0 Second
Edition, so we recommend checking wiki entry Xforms10SecondEdition before
you go deploying it to your users, since it may require changes to your
forms:
 
  <http://www.xforms-wiki.com/bin/view/Main/Xforms10SecondEdition>
 
Regards,
 
Mark
 

Mark Birbeck
CEO
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
b: http://internet-apps.blogspot.com/
w: http://www.formsPlayer.com/

Download our XForms processor from
http://www.formsPlayer.com/ 

 


________________________________

	From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of Olivier.Gaillard@bit.admin.ch
	Sent: 10 January 2006 08:24
	To: www-forms@w3.org
	Subject: XForms: how to disable the use of the XML Schema?
	
	
	Hello,
	 

	I use an XForms whose validation is driven by an XML Schema.
	I'd like to disable the validation on-demand for some elements,
because
	we need to save the data even with empty or not valid values 
	(reason is that we have mostly no rights to edit the data of 
	a client).
	 
	I followed the solution explained by Micah Dubinko in "XForms
	Essentials" pp. 171--172: the controls "Allow Empty PLZ" and "Empty
	PLZ not allow" switch the value of the attribute "required" of
element
	"plz" (ZIP) to "true" or "false".
	 
	All works fine for *empty* values if the XML Schema definition is a
	string and if empty strings are allowed:
	 
	<xs:restriction base="xs:string">
	   <xs:pattern value="([0-9]{4})?"/>
	</xs:restriction>
	 
	
	But if the pattern of the XML Schema does not contain the optional
	sign `?' an empty string is not allowed.
	 
	
	If the definition is changed to integer:
	 
	<xs:element name="codePostal" type="xs:integer" nillable="true"
	minOccurs="0"/>
	 
	and if the ZIP value is empty, there is no validation error (the
	control does not become red), but I get an error message when I
submit
	the form, complaining that the value of ZIP is not an integer.
	 
	 
	 
	As non valid data must be saved the solution cannot come from the
XML
	Schema but from XForms.
	 
	--------
	Question: Is it possible to disable the use of the XML Schema?
	--------
	 
	
	<?xml version="1.0" encoding="ISO-8859-1"?>
	<html xmlns:xf="http://www.w3.org/2002/xforms
<http://www.w3.org/2002/xforms> " 
	      xmlns:xsd="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema> " 
	      xmlns:ev="http://www.w3.org/2001/xml-events
<http://www.w3.org/2001/xml-events> " 
	      xmlns="http://www.w3.org/1999/xhtml
<http://www.w3.org/1999/xhtml> ">
	      <object classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58"
id="formsPlayer"></object>
	      <?import namespace="xf" implementation="#formsPlayer"?>
	 <head>
	 <style type="text/css">
	    .invalid 
	    {
	       background-color: red;
	    }
	    body {background: floralwhite}
	 </style>
	  <xf:model id="m1" schema="./app4b.xsd"> 
	   <xf:instance src="./app4b.xml" />
	   <xf:bind id="villeNom"
nodeset="/form/data/adresse/ville/villeNom" />
	   <xf:bind id="plz" nodeset="/form/data/adresse/ville/codePostal" 
	    required="instance('strict_flag')" />
	   <xf:submission action="xformsHandler.html"
enctype="application/xml" 
	                                encoding="ISO-8859-1" id="submit"
method="post" /> 
	          
	      <xf:submission id="fsubmit" replace="instance" 
	                                action="result.xml"
enctype="application/xml" 
	                                encoding="ISO-8859-1"  method="put"
/>
	   <xf:instance id="strict_flag">
	    <flag>true</flag>
	             </xf:instance>
	  </xf:model>
	      </head>
	      <!-- Formular -->
	  <body>
	 <xf:input bind="villeNom">
	   <xf:label>Ville</xf:label>
	 </xf:input>
	 <br/>
	 
	      
	      <xf:input bind="plz">
	       <xf:label>NPA</xf:label>    
	      </xf:input>
	      
	    <br/>
	  
	     <xf:trigger>
	       <xf:label>Allow empty ZIP</xf:label>
	       <xf:action ev:event="DOMActivate">
	  <xf:setvalue ref="instance('strict_flag')">false</xf:setvalue>
	       </xf:action>
	     </xf:trigger>
	 
	     <br/>
	 
	     <xf:trigger>
	       <xf:label>Empty ZIP not allow</xf:label>
	       <xf:action ev:event="DOMActivate">
	  <xf:setvalue ref="instance('strict_flag')">true</xf:setvalue>
	       </xf:action>
	     </xf:trigger>
	 
	     <br/>
	     <xf:label>Must ZIP be filled?
	       <b><xf:output ref="instance('strict_flag')"></xf:output></b>
	     </xf:label>
	 
	      <br/>
	      <xf:submit submission="fsubmit">
	 <xf:label>Write to disk</xf:label>
	      </xf:submit>
	 
	 </body>
	</html>
	 
	 
	 
	 
	 
	Here's the XML instance:
	<?xml version="1.0" encoding="iso-8859-1"?>
	<form>
	 <data>
	  <adresse>
	   <ville>
	    <villeNom>Be</villeNom>
	    <codePostal>0000</codePostal>
	   </ville>
	  </adresse>
	 </data>
	</form>
	 
	 
	 
	Thanks in advance for your help,
	 
	Olivier
	 

Received on Tuesday, 10 January 2006 11:23:44 UTC