Using Schema datatypes

Next to the standard Schema and XForms datatypes betterFORM provides the possiblity to embed custom types. This can be inline Schema types as well as Schema types within an external Schema file.

Note: Be aware that only XML Schema Simple types are supported by XForms.

Inline Schema

The sample shows how an inline Schema is defined within the host document and referenced from the XForms Model:

<xf:model id="m-schema" schema="#s-schema">
  <xf:instance id="i-listing" xmlns="">
    <data>
      <login/>
    </data>
  </xf:instance>
  <xf:bind nodeset="login" type="login"/>
</xf:model>
<xs:schema id="s-schema">
   <xs:simpleType name="login">
      <xs:restriction base="xs:string">
         <xs:minLength value="4"/>
         <xs:maxLength value="8"/>
         <xs:pattern value="[A-Za-z0-9]+"/>
      </xs:restriction>
   </xs:simpleType>  
</xs:schema>

External Schema

Embinding an external Schema works quite the same as embedding an internal Schema. Only the value of the schema attribute of the XForms model has to be adjusted. Insead of <xf:model schema=”#<internal_schema_id”> the schema is referenced relative or absolute:<xf:model schema=”xsd/MySchema.xsd”>. That’s all, the schema types of MySchema.xsd can now (analog to the internal Schema) be used within the type attribute of XForms bind.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: