6. ATTLIST ELEMENT ID #PCDATA NMTOKEN ENTITY CDATA friend name zip address country city street This is the vocabulary that DTDs provide to define your new vocabulary (Source:Roger L. Costello)
7. element complexType schema sequence http://www.w3.org/2001/XMLSchema string integer boolean This is the vocabulary that XML Schemas provide to define your new vocabulary One difference between XML Schemas and DTDs is that the XML Schema vocabulary is associated with a name (namespace). Likewise, the new vocabulary that you define must be associated with a name (namespace). With DTDs neither set of vocabulary is associated with a name (namespace) [because DTDs pre-dated namespaces]. friend name zip address country city street http://www.galactinav.com ( targetNamespace ) (Source:Roger L. Costello)
8.
9. Referencing a schema in an XML instance document BookStore.xml BookStore.xsd targetNamespace="http://www.books.org" schemaLocation="http://www.books.org BookStore.xsd" - defines elements in namespace http://www.books.org - uses elements from namespace http://www.books.org A schema defines a new vocabulary. Instance documents use that new vocabulary. (Source:Roger L. Costello)
10. Note multiple levels of checking BookStore.xml BookStore.xsd XMLSchema.xsd (schema-for-schemas) Validate that the xml document conforms to the rules described in BookStore.xsd Validate that BookStore.xsd is a valid schema document, i.e., it conforms to the rules described in the schema-for-schemas (Source:Roger L. Costello)
11.
12. Named Types <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.galactinav.com" xmlns="http://www.galactinav.org" elementFormDefault="qualified"> <xsd:element name=“addressbook"> <xsd:complexType> <xsd:sequence> <xsd:element name=“ friend " maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="friend“> <xsd:complexType> <xsd:sequence> <xsd:element name=“name”/> <xsd:element name=“address" type=“addressdata” maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name=“addressdata” > <xsd:sequence> <xsd:element name="street" type=“string”/> <xsd:element name="city" type=“string”/> <xsd:element name="country" type=“string”/> <xsd:element name="zip" type=“string”/> </xsd:sequence> </xsd:complexType> </xsd:schema> The advantage of splitting out friend's element declarations and wrapping them in a named type is that now this type can be reused by other elements. Named type
14. Built-in datatypes Primitive Note: 'T' is the date/time separator INF = infinity NAN = not-a-number a NOTATION from the XML spec NOTATION a namespace qualified name QName http://www.xfront.com anyURI a base64 string base64Binary a hex string hexBinary format: --MM-- gMonth format: ---DD (note the 3 dashes) gDay format: --MM-DD gMonthDay format: CCYY gYear format: CCYY-MM gYearMonth format: CCYY-MM-DD date format: hh:mm:ss.sss time format: CCYY-MM-DDThh-mm-ss dateTime P1Y2M3DT10H30M12.3S duration 12.56E3, 12, 12560, 0, -0, INF, -INF, NAN double 12.56E3, 12, 12560, 0, -0, INF, -INF, NAN float 7.08 decimal {true, false} boolean "Hello World" string
15. Built-in datatypes Derived 1 to infinity positiveInteger 0 to 255 unsignedByte 0 to 65535 unsignedShort 0 to 4294967295 unsignedInt 0 to 18446744073709551615 unsignedLong 0 to infinity nonNegativeInteger -127 to 128 byte -32768 to 32767 short -2147483648 to 2147483647 int -9223372036854775808 to 9223372036854775808 long negative infinity to -1 negativeInteger negative infinity to 0 nonPositiveInteger 456 integer must be used only with attributes ENTITY must be used only with attributes IDREF must be used only with attributes ID part (no namespace qualifier) NCName Name must be used only with attributes NMTOKENS must be used only with attributes NMTOKEN must be used only with attributes ENTITIES must be used only with attributes IDREFS any valid xml:lang value, e.g., EN, FR, ... language String w/o tabs, l/f, leading/trailing spaces, consecutive spaces token A string without tabs, line feeds, or carriage returns normalizedString