This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
notes:xml_schema_cheat_sheet [2026/09/13 11:18] 42.108.141.116 old revision restored (2026/08/03 08:06) |
notes:xml_schema_cheat_sheet [2026/09/14 03:21] (current) 216.73.217.14 old revision restored (2026/09/11 12:03) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== XML Schema ===== | ===== XML Schema ===== | ||
| + | |||
| + | This is a cheat sheet for the XML Schema language. It is a follow up to the [[XML Cheat Sheet]] and summarizes [[http:// | ||
| * XML Schema is an XML-based alternative to DTDs. It is the successor to DTDs because it is richer and more extensible. It describes the structure of an XML document. | * XML Schema is an XML-based alternative to DTDs. It is the successor to DTDs because it is richer and more extensible. It describes the structure of an XML document. | ||
| Line 41: | Line 43: | ||
| * By default an attribute is optional, to make it required add use=" | * By default an attribute is optional, to make it required add use=" | ||
| - | ==== XML Facets / Restrictions ==== | + | ==== Facets / Restrictions ==== |
| * XML Facets are restrictions on the acceptable values for elements or attributes. | * XML Facets are restrictions on the acceptable values for elements or attributes. | ||
| Line 150: | Line 152: | ||
| </ | </ | ||
| - | ==== XSD Element Indicators ==== | + | |
| + | ==== Element Indicators ==== | ||
| * Indicators control how elements are to be used within a complex element. There are three types of indicators: order indicators, occurrence indicators and group indicators | * Indicators control how elements are to be used within a complex element. There are three types of indicators: order indicators, occurrence indicators and group indicators | ||
| Line 174: | Line 177: | ||
| < | < | ||
| - | * An Attribute group is similar | + | * An Attribute group is similar |
| < | < | ||
| < | < | ||
| < | < | ||
| - | </ | + | </ |
| + | < | ||
| + | |||
| + | * Using <xs:any /> as an element allows elements not specified in the schema to occur. | ||
| + | |||
| + | * Using < | ||
| + | |||
| + | * A substitution group allows other elements to substitute for the first. The head elemenet must be a global element (a direct child of the schema element) e.g. < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Data Types ==== | ||
| + | |||
| + | === String Data Types === | ||
| + | |||
| + | * Apart from xs:string there are two other string stypes : | ||
| + | * xs: | ||
| + | * xs:token - No CR, LF or TAB characters are allowed, no leading or trailing spaces are allowed, no sequences of more than one space is allowed | ||
| + | |||
| + | * There are many other types derived from string e.g. NMTOKEN, QName, ID, IDREF. | ||
| + | |||
| + | === Date Data Types === | ||
| + | |||
| + | * date data type is used to specify a date in the format " | ||
| + | |||
| + | * A time data type must be specified in the following format " | ||
| + | |||
| + | * A dateTime datatype must be specified in the following format " | ||
| + | |||
| + | * A timezone can be added to a date/ | ||
| + | |||
| + | * A duration data type must be specified in the following format " | ||
| + | |||
| + | * This is a list of all date types. | ||
| + | |||
| + | ^ Type ^ | ||
| + | | date | Defines a date value (" | ||
| + | |dateTime |Defines a date and time value (" | ||
| + | |duration |Defines a time interval ([-]PnYnMnDTnHnMnS)| | ||
| + | |gDay |Defines a part of a date - the day (DD)| | ||
| + | |gMonth |Defines a part of a date - the month (MM)| | ||
| + | |gMonthDay |Defines a part of a date - the month and day (MM-DD)| | ||
| + | |gYear |Defines a part of a date - the year (YYYY)| | ||
| + | |gYearMonth |Defines a part of a date - the year and month (YYYY-MM)| | ||
| + | |time |Defines a time value (" | ||
| + | |||
| + | === Numeric Data types === | ||
| + | |||
| + | * The xs:decimal data type specifies a positive or negative numeric value (with fractional part). | ||
| + | |||
| + | * The xs:integer data type specifies a positive or negative integer. | ||
| + | |||
| + | * These are all the numeric types, which all derive from the decimal type. | ||
| + | |||
| + | ^Name ^Description^ | ||
| + | |byte |A signed 8-bit integer| | ||
| + | |decimal |A decimal value| | ||
| + | |int |A signed 32-bit integer| | ||
| + | |integer |An integer value| | ||
| + | |long |A signed 64-bit integer| | ||
| + | |negativeInteger |An integer containing only negative values ( .., -2, -1.)| | ||
| + | |nonNegativeInteger |An integer containing only non-negative values (0, 1, 2, ..)| | ||
| + | |nonPositiveInteger |An integer containing only non-positive values (.., -2, -1, 0)| | ||
| + | |positiveInteger |An integer containing only positive values (1, 2, ..)| | ||
| + | |short |A signed 16-bit integer| | ||
| + | |unsignedLong |An unsigned 64-bit integer| | ||
| + | |unsignedInt |An unsigned 32-bit integer| | ||
| + | |unsignedShort |An unsigned 16-bit integer| | ||
| + | |unsignedByte |An unsigned 8-bit integer| | ||
| + | |||
| + | === Other Data Types === | ||
| + | * xs:boolean is a booleantype which must be true or false | ||
| + | * xs: | ||
| + | * xs:anyURI can be used for any URL or URN. | ||
| + | * There are also xs:double and xs:float data types. | ||