XSDL – Part III

XML Foundations (INFO 242)

Erik Wilde, UC Berkeley School of Information
2007-10-30
Creative Commons License

This work is licensed under a CC
Attribution 3.0 Unported License

Abstract

XSDL allows greater flexibility in defining constraints on intra-document references than the ID/IDREF construct of DTDs. XSDL'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.

Outline (Local and Global Definitions)

  1. Local and Global Definitions [6]
    1. Elements [2]
    2. Attributes [3]
  2. Names and Namespaces [3]
  3. Identity Constraints [6]
  4. Conclusions [1]

Named and Anonymous Types

<!ELEMENT person (name, address) >
<!ATTLIST person id ID #REQUIRED >

Outline (Elements)

  1. Local and Global Definitions [6]
    1. Elements [2]
    2. Attributes [3]
  2. Names and Namespaces [3]
  3. Identity Constraints [6]
  4. Conclusions [1]

Local vs. Global Elements

 <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"/>

Reusable Elements

<?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>

Outline (Attributes)

  1. Local and Global Definitions [6]
    1. Elements [2]
    2. Attributes [3]
  2. Names and Namespaces [3]
  3. Identity Constraints [6]
  4. Conclusions [1]

Attribute Definitions

Reusing Attributes

Reusing Attributes (Example)

<?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>

Outline (Names and Namespaces)

  1. Local and Global Definitions [6]
    1. Elements [2]
    2. Attributes [3]
  2. Names and Namespaces [3]
  3. Identity Constraints [6]
  4. Conclusions [1]

Definitions

Instances

<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>Multicolumn Layout in HTML</title>
  <style type="text/css">

Name Qualification

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/" elementFormDefault="qualified" attributeFormDefault="unqualified">

Outline (Identity Constraints)

  1. Local and Global Definitions [6]
    1. Elements [2]
    2. Attributes [3]
  2. Names and Namespaces [3]
  3. Identity Constraints [6]
  4. Conclusions [1]

Element = Type + Constraints

Improvements over ID/IDREF

Types of Identity Constraints

Identity Constraint Definitions

Identity Constraint Evaluation

identity-constraints.png

Advanced Identity Constraints

identity-constraints++.png

Outline (Conclusions)

  1. Local and Global Definitions [6]
    1. Elements [2]
    2. Attributes [3]
  2. Names and Namespaces [3]
  3. Identity Constraints [6]
  4. Conclusions [1]

XSDL Features