XML Training Course - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

XML Training Course

Description:

Discussion of 'well-formed' and 'valid' XML Documents. What is a DTD? Creating a DTD ... Well-formed vs. Valid. Two ways to be 'right' Well-formed all the ... – PowerPoint PPT presentation

Number of Views:351
Avg rating:3.0/5.0
Slides: 19
Provided by: Bowm
Category:

less

Transcript and Presenter's Notes

Title: XML Training Course


1
XML Training Course
  • Module 3 XML Validation with DTDs

2
What to expect this Session
  • Discussion of well-formed and valid XML
    Documents
  • What is a DTD?
  • Creating a DTD
  • Controlling Elements
  • Controlling Attributes
  • Shortcomings of DTDs

3
Well-formed vs. Valid
  • Two ways to be right
  • Well-formed all the syntax rules have been met
  • Valid the document has been successfully
    validated against a defining DTD or XML Schema

4
Document Structures
  • Data must have rules
  • Define what data types
  • Define sizes
  • Define order

5
DTDs Defined
  • Data Type Definitions
  • Used to enforce structure requirements for and
    XML Document

6
DTDs in Use
  • Allowed Tags
  • Allowed elements
  • Allowed attributes
  • of occurrences of each element
  • Order in which elements may appear

7
Declare a DTD
  • XML document declares that it has an associated
    DTD by including the !DOCTYPE tag.
  • lt!DOCTYPE root-element identifier-type
    identifiergt
  • lt!DOCTYPE project_description SYSTEM
    "project.dtd"gt
  • lt!DOCTYPE catalog SYSTEM "catalog.dtd"gt
  • lt!DOCTYPE menu PUBLIC www.cafe.com/menu.dtdgt

8
Create a DTD
  • DTD consists of a list of statements, referred to
    as Content Models.
  • These statements define the allowed and the order
    in which the should appear.
  • General format of the statement looks like
  • lt!ELEMENT elementname (elementtype modifiers)gt
  • lt!ELEMENT Entree (Meat)gtA entrée can contain one
    and only one occurrence of meat.

9
DTD Element Modifiers
10
Example
11
Example, cont
PCDATA Parsed Character Data
12
DTD Attribute Declarations
  • Use the lt!ATTLIST tag to define Attributes.
  • General format looks like this
  • lt!ATTLIST associatedelement
  • attributename1 attributetype1 modifiers
  • attributename2 attributetype2 modifiers
  • ...
  • attributenameN attributetypeN modifiersgt

13
DTD Attribute Types
14
DTD Attribute Modifiers
15
Example, cont
16
DTDs Shortcoming
  • They can only validate structure of a document.
  • They can not enforce any type of rules for a
    particular element.
  • To enforce rules use and XML Schema

17
Review this Session
  • Discussion of well-formed and valid XML
    Documents
  • What is a DTD?
  • Creating a DTD
  • Controlling Elements
  • Controlling Attributes
  • Shortcomings of DTDs

18
Build an XML DTD
Write a Comment
User Comments (0)
About PowerShow.com