This work is licensed under a Creative Commons |
XML Schema allows greater flexibility in defining constraints on intra-document references than the ID/IDREF construct of DTDs. XML Schema's Identity Constraints are scoped, typed, and can be used for elements or attributes. The second aspect of XML Schema discussed today is the derivation of complex types. Complex types can be derived by restriction or extension. Complex type restriction defines the restricted type to be a more restricted version of the base type. Complex type extension make it possible to extend the base type by either adding attributes or contents (only by appending new content to the content model).
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"/>
ATTLIST
, not in the ELEMENT
definition<!ELEMENT person (name, address) >
<!ATTLIST person id ID #REQUIRED >
<!ATTLIST person id ID #REQUIRED >
ATTLIST
<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">
ID
s must be XML names (no numbers allowed)2
≟ +00002
should be evaluated based on the type (string or decimal?)US
use="optional"
use="required"
or use="prohibited"
handling extensionscan be as simple as skipping them