|
XSD Syntax
Part:
1
2
3
This tutorial describes:
- Simple XML Elements with Pre-defined Data Types
- Simple XML Elements with Extended Data Types
- Complex XML Elements
- Simple Content XML Elements
- Empty XML Elements
- Anomymous Data Types
- Sample XSD File - dictionary.xsd
Simple XML Elements with Pre-defined Data Types
Simple XML Element: An XML element that has no child elements and attributes.
Simple XML elements can be defined in XSD with the following statement:
<xsd:element name="element_name" type="xsd:type_name"/>
where "element_name" is the name of the XML element, and "type_name" is
one of the data type names pre-defined in XSD.
XSD pre-defined data types are divided into 7 groups:
- Numeric data types
- Date and time data types
- String data types
- Binary data types
- Boolean data type
Numeric data types: All commonly used integer and real number types:
- xsd:float
- xsd:double
- xsd:decimal
- xsd:integer
- xsd:nonPositiveInteger
- xsd:nonNegativeInteger
- xsd:negativeInteger
- xsd:positiveinteger
- xsd:long
- xsd:int
- xsd:short
- xsd:byte
- xsd:unsignedLong
- xsd:unsignedInt
- xsd:unsignedShort
- xsd:unsignedByte
Date and time data types: Date and time related data types. Constants of date and time
types are written in the format defined by ISO 8601. For example:
"2002-12-23T14:19:00.000-05:00" represents an instance of time at 14:19:00.000 on
December 23, 2003, with 5:00 time zone adjustment.
- xsd:dateTime - Date and time, like "2002-12-23T14:19:00.000-05:00".
- xsd:date - Date only, like "2002-12-23".
- xsd:time - Time only, like "14:19:00.000-05:00".
- xsd:gDay - Day only, like "--23" (the 23rd day of any month of any year).
- xsd:gMonth - Month only, like "-12" (December of any year).
- xsd:gYear - Year only, like "2002".
- xsd:gYearMonth - Year and month only, like "2002-12".
- xsd:gMonthDay - Month and day only, like "-12-23".
- xsd:duration - Period of time, like "P0001Y02M03DT04H05M06.000S".
String data types: String related data types.
- xsd:string - A sequence of any Unicode characters
- xsd:normalizedString - A string with no tabs, carriage returns, or line feeds
- xsd:token - A normalized string with no any leading and trailing spaces,
and no multiple consecutive spaces.
Binary data types:
- xsd:hexBinary - A sequence of hex digits to represent any binary data.
- xsd:base64Binary - Binary data written in Base64 encoding
Boolean data type:
- xsd:boolean - With 4 possible values: 0, 1, true, false.
One example of using pre-defined XSD data types is in our hello_xsd.xml:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="p" type="xsd:string"/>
</xsd:schema>
where element "p" is defined to be a simple element type allowing child text node
containing data of "xsd:string" type.
(Continued on next part...)
Part:
1
2
3
|