Datatypes supported by sample implementation of TREX in Java

The sample implementation of TREX in Java supports XML Schema Part 2 as its datatyping language. The version of XML Schema currently supported is the Candidate Recommendation.

Named datatypes

Datatypes are supported as follows:

string
Fully supported.
boolean
Fully supported.
float
Fully supported.
double
Fully supported.
decimal
Fully supported.
timeDuration
Partially supported: validated like string.
recurringDuration
Not supported.
binary
Not supported.
uriReference
Partially supported: validated like string.
ID
Partially supported: validated like NCName.
IDREF
Partially supported: validated like NCName.
ENTITY
Partially supported: validated like NCName.
QName
Fully supported.
CDATA
Fully supported.
token
Fully supported.
language
Partially supported: validated like string.
IDREFS
Partially supported: validated like list of NCName.
ENTITIES
Partially supported: validated like list of NCName.
NMTOKEN
Fully supported.
NMTOKENS
Fully supported.
Name
Fully supported.
NCName
Fully supported.
NOTATION
Partially supported: validated like Name.
integer
Fully supported.
nonPositiveInteger
Fully supported.
negativeInteger
Fully supported.
long
Fully supported.
int
Fully supported.
short
Fully supported.
byte
Fully supported.
nonNegativeInteger
Fully supported.
unsignedLong
Fully supported.
unsignedInt
Fully supported.
unsignedShort
Fully supported.
unsignedByte
Fully supported.
positiveInteger
Fully supported.
timeInstant
Partially supported: validated like string.
time
Not supported.
timePeriod
Not supported.
date
Not supported.
month
Not supported.
year
Not supported.
century
Not supported.
recurringDate
Not supported.
recurringDay
Not supported.

Anonymous datatypes

Derivation of new datatypes by restriction, list and union is supported. The element bearing the trex:role="datatype" attribute must be a restriction, list, union or simpleType element.

Facets are supported as follows:

length
Fully supported.
minLength
Fully supported.
maxLength
Fully supported.
pattern
Fully supported, but requires external regular expression package.
enumeration
Fully supported.
whiteSpace
Fully supported.
maxInclusive
Fully supported.
maxExclusive
Fully supported.
minInclusive
Fully supported.
minExclusive
Fully supported.
precision
Fully supported.
scale
Fully supported.
encoding
Not supported.
duration
Not supported.
period
Not supported.

The implementation of the pattern facet requires an implementation of regular expressions as defined in XML Schema Part 2. The name of the class implementing the interface com.thaiopensource.datatype.xsd.RegexEngine must be specified as the value of the com.thaiopensource.trex.util.RegexEngine system property. If no such class is available, then any pattern will be assumed to match any string.

The class com.thaiopensource.trex.util.XercesRegexEngine implements com.thaiopensource.datatype.xsd.RegexEngine using the package org.apache.xerces.utils.regex which is included in the Xerces XML Parser. To use this, an option of

-Dcom.thaiopensource.trex.util.RegexEngine=com.thaiopensource.trex.util.XercesRegexEngine

would be added to the invocation of the java command. There is a trivial bug in the current (1.3.0) version of Xerces, which makes invalid regular expressions cause a NullPointerException. The bug report describes a workaround.

Alternatively, you can use IBM's Regex for Java package, available from Alphaworks. You can create a RegexEngine that uses this simply by changing org.apache.xerces.utils to com.ibm in com/thaiopensource/trex/util/XercesRegexEngine.java. The sample implementation does not include such a class because the license for Regex for Java is currently rather restrictive.