Data Modeling
Data Modeling
Data Modeling
Data Modeling
Document Modeling
Document Model
A document model defines a set of element names and attributes
that can appear in an XML document.
A validating XML parser can not only read XML documents, but verify
that they conform to a specific schema.
Example of a DTD
<?xml version=“1.0” encoding=“UTF-8”?>
<!– The DTD follows... -->
<!DOCTYPE people
[
<!ELEMENT people (person+)>
<!ELEMENT person (name)>
<!ELEMENT name (first, last)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT last (#PCDATA)>
]>
<!–- The XML data begins here... -->
<people>
<person>
<name>
<first>Erik</first>
<last>Westermann</last>
</name>
</person>
<person>
<name>
<first>Tom</first>
<last>Archer</last>
</name>
</person>
</people>
Disadvantages of DTD
-DTDs use a specialized syntax that’s different from XML, making
them more difficult to learn for people without a background in SGML
or XML
-DTDs don’t allow you to specify which type of data an element can
contain.
-DTDs have a fixed, non-extensible content model that doesn’t allow
developers to create new elements and attributes.
-DTDs don’t support namespaces.
Data Modeling with XDR Schema
XDR, or XML Data Reduced, is an XML vocabulary invented by
Microsoft taht allows you to describe the schema of an XML
document.
The XDR describes that schema in terms of not only the document’s
content, but also which types of content are contained in the
document’s elements.
The XSD describes the XML Document in terms of its data types.
An Example of XSD
<?xml version=“1.0” encoding=“UTF-8”?>
<xs:schema xmlns:xs=“http://www.w3.org/2001/XMLSchema”
elementFormDefault=“qualified”>
<xs:element name=“first” type=“xs:string”/>
<xs:element name=“last” type=“xs:string”/>
<xs:element name=“name”>
<xs:complexType>
<xs:sequence>
<xs:element ref=“first”/>
<xs:element ref=“last”/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name=“people”>
<xs:complexType>
<xs:sequence>
<xs:element ref=“person” maxOccurs=“unbounded”/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name=“person”>
<xs:complexType>
<xs:sequence>
<xs:element ref=“name”/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Which Dat Modelling Schema Should I use?
DTDs
-Have been around for a long time and enjoy broad support from a
wide range of products and vendors
-Generally well-understood
XDR
-Microsoft-specific technology. Limited support in the industry.
XSD
-W3C Standard. Broader acceptance from vendors.
-New in the market.