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

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

From: <Olivier.Gaillard@bit.admin.ch>
Date: Tue, 10 Jan 2006 09:24:27 +0100
Message-ID: <F9017844DF95F047B04B382336E68BEB030753F6@ad04mexefd4.ad.admin.ch>
To: www-forms@w3.org

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})?"/>

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"
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>
      xmlns:xsd=" <http://www.w3.org/2001/XMLSchema>
      xmlns:ev=" <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"
      <?import namespace="xf" implementation="#formsPlayer"?>
 <style type="text/css">
       background-color: red;
    body {background: floralwhite}
  <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" 
                                encoding="ISO-8859-1"  method="put" />
   <xf:instance id="strict_flag">
      <!-- Formular -->
 <xf:input bind="villeNom">
      <xf:input bind="plz">
       <xf:label>Allow empty ZIP</xf:label>
       <xf:action ev:event="DOMActivate">
  <xf:setvalue ref="instance('strict_flag')">false</xf:setvalue>
       <xf:label>Empty ZIP not allow</xf:label>
       <xf:action ev:event="DOMActivate">
  <xf:setvalue ref="instance('strict_flag')">true</xf:setvalue>
     <xf:label>Must ZIP be filled?
       <b><xf:output ref="instance('strict_flag')"></xf:output></b>
      <xf:submit submission="fsubmit">
 <xf:label>Write to disk</xf:label>
Here's the XML instance:
<?xml version="1.0" encoding="iso-8859-1"?>
Thanks in advance for your help,
Received on Tuesday, 10 January 2006 09:47:13 UTC

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