W3C

Analysis of using XML Schemas Datatypes in the XForms Data Model


Abstract

This document is an analysis by the XForms Working Group of the applicability of XML Schemas part 2: Datatypes [XSchema-2] to defining the datatypes in the XForms Data Model [XForms-DM], and highlights the similarities and difference between this approach and the existing data model.


Table of Contents

1 Introduction
2 Common Facets
    2.1 Similarities
    2.2 Differences
    2.3 Usage Comparison
        2.3.1 XML Schema syntax
        2.3.2 XForms syntax
3 string
    3.1 Declared as a SimpleType
    3.2 Similarities
    3.3 Differences
    3.4 Usage Comparison
        3.4.1 XML Schema syntax
        3.4.2 XForms syntax
4 boolean
    4.1 Declared as a SimpleType
    4.2 Similarities
    4.3 Differences
    4.4 Usage Comparison
        4.4.1 XML Schema syntax
        4.4.2 XForms syntax
5 number
    5.1 Declared as a SimpleType
    5.2 Similarities
    5.3 Differences
    5.4 Usage Comparison
        5.4.1 XML Schema syntax
        5.4.2 XForms syntax
6 money
    6.1 Declared as a SimpleType
    6.2 Similarities
    6.3 Differences
    6.4 Usage Comparison
        6.4.1 XML Schema syntax
        6.4.2 XForms syntax
7 date
    7.1 Declared as a SimpleType
    7.2 Similarities
    7.3 Differences
    7.4 Usage Comparison
        7.4.1 XML Schema syntax
        7.4.2 XForms syntax
8 time
    8.1 Declared as a SimpleType
    8.2 Similarities
    8.3 Differences
    8.4 Usage Comparison
        8.4.1 XML Schema syntax
        8.4.2 XForms syntax
9 duration
    9.1 Declared as a SimpleType
    9.2 Similarities
    9.3 Differences
    9.4 Usage Comparison
        9.4.1 XML Schema syntax
        9.4.2 XForms syntax
10 uri
    10.1 Declared as a SimpleType
    10.2 Similarities
    10.3 Differences
    10.4 Usage Comparison
        10.4.1 XML Schema syntax
        10.4.2 XForms syntax
11 binary
    11.1 Declared as a SimpleType
    11.2 Similarities
    11.3 Differences
    11.4 Usage Comparison
        11.4.1 XML Schema syntax
        11.4.2 XForms syntax

Appendix

A References


1 Introduction

The XForms Data Model [XForms-DM] contains datatypes that are not derived from XML Schema Part 2: Datatypes [XSchema-2]. In response to a request made by the XML Schema Working Group in their comments on XForms Data Model, and as part of an ongoing effort to bring these two technologies closer together, the XForms Working Group has produced this gap analysis listing the discrepencies between [XForms-DM] and one using datatypes derived from [XSchema-2].

Each of the sections that follow include a "best effort" XML Schema SimpleType declaration loosely fashioned after one of the datatypes defined in [XForms-DM], followed by a list of the similarities and differences between this SimpleType and the original XForms datatype, and a typical usage comparison.

The xsd: prefix is used throughout this document to differentiate XML Schema constructs (facets and datatypes belonging to the http://www.w3.org/1999/XMLSchema namespace) from those defined in XForms.

2 Common Facets

2.1 Similarities

  • All datatypes have a value facet which is similar to the xsd:enumeration facet

  • All datatypes have a default facet is similar to an XML Schema attribute declaration where use="default" and value is set to the default attribute value, or an XML Schema element declaration where default is set to the default element value.

2.2 Differences

  • XForms range facet allows type values to be one of an enumerated set of literal values or a free form value. There is no equivalent XML Schema facet.

  • For all types but string the XML Schema xsd:pattern and xsd:enumeration facets have no counterparts in XForms

  • XForms has no provision for the reuse of user-defined datatypes.

  • XSchema has the ability to derive any SimpleType "by list".

2.3 Usage Comparison

2.3.1 XML Schema syntax

<xsd:element name="maritalStatus" default="married">
  <xsd:simpleType base="string">
    <xsd:enumeration value="single"/>
    <xsd:enumeration value="married"/>
  </xsd:simpleType>
</xsd:element>

2.3.2 XForms syntax

<string name="maritalStatus">
  <value>single</value>
  <value>married</value>
</string>

3 string

3.1 Declared as a SimpleType

<xsd:simpleType name="string" base="xsd:string"/>

3.2 Similarities

  • Regular expression pattern facet support is identical to the xsd:pattern facet, however XForms may drop this in favor of the simpler mask facet.

  • min and max facets are identical to the xsd:minLength and xsd:maxLength facets

3.3 Differences

  • mask facet has no XML Schema counterpart

  • xsd:length facet has no XForms counterpart

  • XForms has no concept of string ranges (xsd:minExclusive, xsd:maxExclusive, xsd:minInclusive, and xsd:maxInclusive)

3.4 Usage Comparison

3.4.1 XML Schema syntax

<xsd:element name="socialSecurityNumber">
  <xsd:simpleType base="string">
    <xsd:pattern value="\d{3}-\d{2}-\d{4}"/>
  </xsd:simpleType>
</xsd:element>

3.4.2 XForms syntax

<string name="socialSecurityNumber">
  <mask>nnn-nn-nnnn</mask>
</string>

4 boolean

4.1 Declared as a SimpleType

<xsd:simpleType name="boolean" base="xsd:boolean">
  <xsd:enumeration value="true"/>
  <xsd:enumeration value="false"/>
</xsd:simpleType>

4.2 Similarities

  • Use of 'true' and 'false' literals

4.3 Differences

  • XML Schema allows '0' and '1' in addition to 'true' and 'false'

4.4 Usage Comparison

4.4.1 XML Schema syntax

<xsd:element name="isRequired" default="true">
  <xsd:simpleType base="boolean"/>
</xsd:element>

4.4.2 XForms syntax

<boolean name="isRequired" default="true"/>

5 number

5.1 Declared as a SimpleType

<xsd:simpleType name="number" base="xsd:decimal"/>

5.2 Similarities

  • min and max facets are identical to thexsd:minInclusive and xsd:maxInclusive facets

  • decimals facet is identical to thexsd:scalefacet

5.3 Differences

  • Setting the XForms integer facet to 'true' is analogous to setting the XML Schema xsd:scale facet to 0

  • xsd:precision facet has no counterpart in XForms

  • XForms has no concept of exclusive numeric rangesxsd:maxExclusive, xsd:minExclusive facets)

5.4 Usage Comparison

5.4.1 XML Schema syntax

<xsd:element name="floor">
  <xsd:simpleType base="number">
    <xsd:scale value="0"/>
    <xsd:minInclusive value="1"/>
    <xsd:maxInclusive value="200"/>
  </xsd:simpleType>
</xsd:element>

5.4.2 XForms syntax

<number name="floor" integer="true" min="1" max="200"/>

6 money

6.1 Declared as a SimpleType

<xsd:simpleType name="money" base="xsd:decimal"/>

6.2 Similarities

  • min and max facets are identical to thexsd:minInclusive and xsd:maxInclusive facets

  • decimals facet is identical to thexsd:scalefacet

6.3 Differences

  • XForms currency facet has no XML Schema counterpart

  • xsd:precision facet has no counterpart in XForms

  • XForms has no concept of exclusive numeric ranges (XML Schema facets:maxExclusive, minExclusive)

6.4 Usage Comparison

6.4.1 XML Schema syntax

<xsd:element name="price">
  <xsd:simpleType base="money">
    <xsd:scale value="2"/>
    <!-- cannot specify currency -->
  </xsd:simpleType>
</xsd:element>

6.4.2 XForms syntax

<money name="price" decimals="2" currency="USD"/>

7 date

7.1 Declared as a SimpleType

<xsd:simpleType name="date" base="xsd:date"/>

7.2 Similarities

  • Lexical format is identical when XForms precision facet is set to 'years'

  • min and max facets are identical to thexsd:minInclusive and xsd:maxInclusive facets

7.3 Differences

  • XForms precision facet has no direct counterpart in XML Schema. Setting precision to 'months' is analogous to constrainingxsd:duration to 'P1M', and settingprecision to 'days' is analogous to constrainingxsd:duration to 'P1D'.

  • XForms allows the use of relative durations ('+P2D') for both themin and max facets. XML Schema requires that ranges are specified using absolute values.

  • XForms allows the literal value 'now' for both theminandmax facets. XML Schema has no concept of 'now'.

  • xsd:precision facet has no counterpart in XForms

  • XForms has no concept of exclusive temporal rangesxsd:maxExclusive, and xsd:minExclusive)

  • XML Schema xsd:period facet has no counterpart in XForms

7.4 Usage Comparison

7.4.1 XML Schema syntax

<xsd:element name="birthDate">
  <xsd:simpleType base="date">
    <!-- cannot specify a maximum of "now" -->
    <xsd:maxInclusive value="2000-05-15"/>
  </xsd:simpleType>
</xsd:element>

7.4.2 XForms syntax

<date name="birthDate" max="now"/>

8 time

8.1 Declared as a SimpleType

<xsd:simpleType name="time" base="xsd:time"/>

8.2 Similarities

  • Setting the XForms precision facet to 'hours', 'minutes', or 'seconds' is roughly analogous to setting the XML Schema xsd:period facet to 'PT24H', 'PT60M', and 'PT60S', respectively.

  • min and max facets are identical to thexsd:minInclusive and xsd:maxInclusive facets

8.3 Differences

  • xsd:precision facet has no counterpart in XForms

  • XForms has no concept of exclusive temporal rangesxsd:maxExclusive, and xsd:minExclusive)

8.4 Usage Comparison

8.4.1 XML Schema syntax

<xsd:element name="meetingTime">
  <xsd:simpleType base="time"/>
</xsd:element>

8.4.2 XForms syntax

<time name="meetingTime"/>

9 duration

9.1 Declared as a SimpleType

<xsd:simpleType name="duration" base="xsd:timeDuration"/>

9.2 Similarities

  • Lexical values are identical.

9.3 Differences

  • XForms precision facet has no counterpart in XML Schema.

  • XForms has no concept of temporal duration rangesxsd:maxInclusive,xsd:minInclusive,xsd:maxExclusive, andxsd:minExclusive)

9.4 Usage Comparison

9.4.1 XML Schema syntax

<xsd:element name="runningTime">
  <xsd:simpleType name="duration"/>
</xsd:element>

9.4.2 XForms syntax

<duration name="runningTime"/>

10 uri

10.1 Declared as a SimpleType

<xsd:simpleType name="uri" base="xsd:uriReference"/>

10.2 Similarities

  • Lexical values are identical.

10.3 Differences

  • While the XForms scheme facet has no direct counterpart in XML Schema, the xsd:pattern facet can be used instead.

  • xsd:length, xsd:minLength, andxsd:maxLength facets have no counterparts in XForms

10.4 Usage Comparison

10.4.1 XML Schema syntax

<xsd:element name="homepage">
  <xsd:simpleType base="uri">
    <xsd:pattern value="http:.+"/>
  </xsd:simpleType>
</xsd:element>

10.4.2 XForms syntax

<uri name="homepage" scheme="http"/>

11 binary

11.1 Declared as a SimpleType

<xsd:simpleType name="binary" base="xsd:binary"/>

11.3 Differences

  • XForms type facet has no direct counterpart in XML Schema.

  • xsd:encoding,xsd:length,xsd:minLength, andxsd:maxLength facets have no counterparts in XForms

11.4 Usage Comparison

11.4.1 XML Schema syntax

<xsd:element name="uploadFile">
  <xsd:simpleType base="binary">
    <xsd:encoding value="base64"/>
    <!-- cannot specify MIME type -->
  </xsd:simpleType>
</xsd:element>

11.4.2 XForms syntax

<binary name="uploadImage" type="image/jpeg"/>