[http://creativecommons.org/licenses/by/3.0/]
This work is licensed under a CC
Attribution 3.0 Unported License [http://creativecommons.org/licenses/by/3.0/]
XSD allows greater flexibility in defining constraints on intra-document references than the ID/IDREF construct of DTDs. XSD's Identity Constraints are scoped, typed, and can be used for elements or attributes. They are more powerful that the DTD's limited ID/IDREF mechanism, but still lack sufficient generality to support a really wide set of model constraints to be expressed.
typesare always anonymous (they cannot be reused)
<!ELEMENT person (name, address) >
<!ATTLIST person id ID #REQUIRED ><xs:complexType name="mixedType" mixed="true"> <xs:choice maxOccurs="unbounded" minOccurs="0"> <xs:element ref="b"/> <xs:element name="i" type="xs:string"/> <xs:element name="u" type="xs:string"/> </xs:choice> <xs:attribute ref="class"/> </xs:complexType> <xs:element name="b" type="xs:string"/>
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="billingAddress" type="addressType"/> <xs:element name="shippingAddress" type="addressType"/> <xs:complexType name="addressType"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="street" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="state" type="xs:string" minOccurs="0"/> <xs:element name="zip" type="xs:decimal"/> </xs:sequence> <xs:attribute name="country" type="xs:NMTOKEN"/> </xs:complexType> </xs:schema>
ATTLIST, not in the ELEMENT definition<!ELEMENT person (name, address) >
<!ATTLIST person id ID #REQUIRED ><!ATTLIST person id ID #REQUIRED >ATTLIST<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="p" type="mixedType"/>
<xs:complexType name="mixedType" mixed="true">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element ref="b"/>
<xs:element name="i" type="xs:string"/>
<xs:element name="u" type="xs:string"/>
</xs:choice>
<xs:attribute ref="class"/>
</xs:complexType>
<xs:element name="b" type="xs:string"/>
<xs:attribute name="class">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="comment"/>
<xs:enumeration value="warning"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:schema><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Multicolumn Layout in HTML</title> <style type="text/css">
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/" elementFormDefault="qualified" attributeFormDefault="unqualified">IDs must be XML names (no numbers allowed)2 ≟ +00002 should be evaluated based on the type (string or decimal?)
