3. A document model defines a set of element names and attributes
that can appear in an XML document.
A document model, more formally and generally known as a data
model, describes the logical structure of a set of data.
The data model specifies which information a data set contains in
terms of the names of the fields, which data each field can contain,
and the relationships between fields and other sets of data.
Document Model
4. -You want to define an XML vocabulary, and you need to ensure that
people can computers produce XML documents that conform on the
vocabulary.
-You want to reduce the cost of creating a new XML-aware
application.
-You want to ensure that XML documents meet a certain level of
quality, in terms of their structure and the data that they contain.
-XML documents are created by people or other applications and are
consumed (read) by other applications.
A data model becomes important in the
following scenarios:
5. There are three major technologies that you can use to create a data
model for your XML documents:
-DTD
-XDR Schema
-XML Schema
Types of Data Models
6. DTD, or Document Type Definition, is a technology thatâs part of the
XML specification. This means that all validating XML parsers must be
able to read and work with a DTD.
A validating XML parser can not only read XML documents, but verify
that they conform to a specific schema.
Data Modeling with DTD
7. <?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)>
]>
Example of a DTD
8. <!â- 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>
9. -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.
Disadvantages of DTD
10. 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 primary drawback to using XDR is that itâs limited to Microsoft
products and technologies â other vendors donât support XDR.
Data Modeling with XDR Schema
13. XSD, the XML Schema Definition, is a W3C recommendation that
allows you to describe XML schemas using an XML vocabulary.
The XSD describes the XML Document in terms of its data types.
Data Modeling with XSD
14. <?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>
An Example of XSD
16. 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.
Which Dat Modelling Schema Should I use?