-
Notifications
You must be signed in to change notification settings - Fork 5
XSSimpleType
XSSimpleType is a class which instances represent XML Schema's simple type definitions.
Some of them are predefined, they correspond to built in datatypes. Others are constructed while loading XMLSchemata. Anyway, those are internal objects mostly used by XMLMarshaller.stringify ().
The main method, stringify (value), maps an arbitrary non-nullish value into the corresponding string from the type's lexical space, or throws an error when the argument is unacceptable. In the base implementation, it simply calls toString(), but specific ancestor classes do some necessary validation and conversion.
| Subclass | XML Types | Acceptable Values |
|---|---|---|
XSSimpleTypeBoolean |
boolean |
true, false, 'true', 'false', 1, 0, '1', '0'
|
XSSimpleTypeDate |
date |
Date, String (ISO) |
XSSimpleTypeDateTime |
dateTime |
Date, String (ISO) |
XSSimpleTypeDecimal |
decimal |
! isNaN() |
XSSimpleTypeInteger |
integer |
Number.isInteger() |
XSSimpleTypeFloat |
double, float
|
! isNaN() |
XSSimpleTypeQName |
QName |
{localName, namespaceURI} |
XSSimpleType |
all other | non-nullish |
In general, the output is not guaranteed to be valid for any possible incoming value. There is a certain functionality/performance trade-off here. For instance, XSSimpleTypeDateTime passes through any 10 char string as is, without spending CPU cycles to check for YYYY-MM-DD format, month number, leap year etc. The application developer is expected to supply some reasonable content. It's OK to supply a dateTime value for a date placeholder, the time part will be truncated, but xml-toolkit will never try to fix any random content.