See XML and Localization :: FAQ :: Character Representation
See XML and Localization :: FAQ :: Encoding
See XML and Localization :: FAQ :: Language Identification
XML DTDs (Document Type Definitions) are good for describing document structure e.g.
<!ELEMENT book (preface?, chapter+, index)>
<!ELEMENT chapter (section+)>
<!ELEMENT section (#PCDATA)>
<age> 45 </age>
<height> 5.9 </height>
<color> blue </color>
<element name="age" type="positiveInteger"/>
<element name="height" type="float"/>
<element name="color">
<simpleType base="xsd:string">
<enumeration value="green">
<enumeration value="blue">
</simpleType>
</element>
<simpleType name='sizes'>
<list itemType='decimal'/>
<simpleType>
with example data
<cerealSizes xsi:type='sizes'> 8 10.5 12 </cerealSizes>
Most XML standard data type are represented by a Java data type
XML | Java |
---|---|
boolean | boolean |
byte | byte |
dateTime | java.util.Calendar |
double | double |
float | float |
int | int |
integer | java.math.BigInteger |
string | String |
Some types can't be represented since they don't exist in Java,
such as unsigned int
. If a type can be "nillable"
(that is, have a nil
value) and it would be a
Java primitive type, then it is wrapped in a Java class such
as Integer
.
date
time
dateTime
double
integer
2005-05-31
considered
locale independent? Because: it contains enough information
that it can be translated into a date of any calendar
duration
gYearMonth
gYear
gMonthDay
gDay
gMonth
gYear
2005 is ambiguously
either 1425H or 1426H. Similarly, it can be the year 2547 or 2548 in
the Thai calendar (switching at the 13 May)
<xsd:attribute name="size">
<xsd:simpleType>
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:positiveInteger">
<xsd:minInclusive value="8"/>
<xsd:maxInclusive value="72"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="small"/>
<xsd:enumeration value="medium"/>
<xsd:enumeration value="large"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
</xsd:attribute>
<measure>
<value>20</value>
<unit>cm</unit>
</measure>