Re: WXS types in XForms

Alexander Anokhin wrote:

> Hello, all.
>
> I'm trying to assign some validation job to XForms.
> For example: I want to bind <xform:input> with such WXS-type when it's 
> value is decimal with maximum 5 digits OR user may leave this field 
> empty (kind of optional search parameter).
> My guess, is that i'll be like this:
>             <xsd:simpleType name="myType">
>                 <xsd:restriction base="xsd:decimal">
>                     <xsd:minInclusive value="0"/>
>                     <xsd:fractionDigits value="5"/>
>                 </xsd:restriction>
>             </xsd:simpleType>
> but when such field is empty (right after Xform is loaded or user 
> desided that way) it fires xforms-invalid event and so on..
>
> I did some workaround by using <xsd:pattern>:
>
>             <xsd:simpleType name="myType">
>                 <xsd:restriction base="xsd:string">
>                     <xsd:pattern value="[0-9]{1,5}|"/>
>                 </xsd:restriction>
>             </xsd:simpleType>
>
> Works fine but, imho, not such pretty.
>
> I'm not an WXS expert so is there better way?


Hello,

I believe the problem arises from null (the empty string) not being a 
valid number. The same goes for dates, and I've used the following solution:
  <simpleType name="null_date">
    <union>
      <simpleType>
        <restriction base="date">
        </restriction>
      </simpleType>
      <simpleType>
        <annotation>
          <documentation>The empty string</documentation>
        </annotation>
        <restriction base="string">
          <length value="0"/>
        </restriction>
      </simpleType>
    </union>
  </simpleType>

HTH

-- 
Victor Engmark
"Quid quid latine dictum sit, altum viditar" - "What is said in latin, 
sounds profound"

Received on Friday, 8 April 2005 07:18:48 UTC