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.
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
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.
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.
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".
<xsd:element name="maritalStatus" default="married"> <xsd:simpleType base="string"> <xsd:enumeration value="single"/> <xsd:enumeration value="married"/> </xsd:simpleType> </xsd:element> |
<string name="maritalStatus"> <value>single</value> <value>married</value> </string> |
<xsd:simpleType name="string" base="xsd:string"/> |
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
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
)
<xsd:element name="socialSecurityNumber"> <xsd:simpleType base="string"> <xsd:pattern value="\d{3}-\d{2}-\d{4}"/> </xsd:simpleType> </xsd:element> |
<string name="socialSecurityNumber"> <mask>nnn-nn-nnnn</mask> </string> |
<xsd:simpleType name="boolean" base="xsd:boolean"> <xsd:enumeration value="true"/> <xsd:enumeration value="false"/> </xsd:simpleType> |
Use of 'true' and 'false' literals
XML Schema allows '0' and '1' in addition to 'true' and 'false'
<xsd:element name="isRequired" default="true"> <xsd:simpleType base="boolean"/> </xsd:element> |
<boolean name="isRequired" default="true"/> |
<xsd:simpleType name="number" base="xsd:decimal"/> |
min
and max
facets are identical to
thexsd:minInclusive
and xsd:maxInclusive
facets
decimals
facet is identical to
thexsd:scale
facet
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)
<xsd:element name="floor"> <xsd:simpleType base="number"> <xsd:scale value="0"/> <xsd:minInclusive value="1"/> <xsd:maxInclusive value="200"/> </xsd:simpleType> </xsd:element> |
<number name="floor" integer="true" min="1" max="200"/> |
<xsd:simpleType name="money" base="xsd:decimal"/> |
min
and max
facets are identical to
thexsd:minInclusive
and xsd:maxInclusive
facets
decimals
facet is identical to
thexsd:scale
facet
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
)
<xsd:element name="price"> <xsd:simpleType base="money"> <xsd:scale value="2"/> <!-- cannot specify currency --> </xsd:simpleType> </xsd:element> |
<money name="price" decimals="2" currency="USD"/> |
<xsd:simpleType name="date" base="xsd:date"/> |
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
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
themin
andmax
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
<xsd:element name="birthDate"> <xsd:simpleType base="date"> <!-- cannot specify a maximum of "now" --> <xsd:maxInclusive value="2000-05-15"/> </xsd:simpleType> </xsd:element> |
<date name="birthDate" max="now"/> |
<xsd:simpleType name="time" base="xsd:time"/> |
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
xsd:precision
facet has no counterpart in XForms
XForms has no concept of exclusive temporal
rangesxsd:maxExclusive
, and xsd:minExclusive
)
<xsd:element name="meetingTime"> <xsd:simpleType base="time"/> </xsd:element> |
<time name="meetingTime"/> |
<xsd:simpleType name="duration" base="xsd:timeDuration"/> |
Lexical values are identical.
XForms precision
facet has no counterpart in XML Schema.
XForms has no concept of temporal duration
rangesxsd:maxInclusive
,xsd:minInclusive
,xsd:maxExclusive
,
andxsd:minExclusive
)
<xsd:element name="runningTime"> <xsd:simpleType name="duration"/> </xsd:element> |
<duration name="runningTime"/> |
<xsd:simpleType name="uri" base="xsd:uriReference"/> |
Lexical values are identical.
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
<xsd:element name="homepage"> <xsd:simpleType base="uri"> <xsd:pattern value="http:.+"/> </xsd:simpleType> </xsd:element> |
<uri name="homepage" scheme="http"/> |
<xsd:simpleType name="binary" base="xsd:binary"/> |
none.
XForms type
facet has no direct counterpart in XML Schema.
xsd:encoding
,xsd:length
,xsd:minLength
,
andxsd:maxLength
facets have no counterparts in XForms
<xsd:element name="uploadFile"> <xsd:simpleType base="binary"> <xsd:encoding value="base64"/> <!-- cannot specify MIME type --> </xsd:simpleType> </xsd:element> |
<binary name="uploadImage" type="image/jpeg"/> |