Your SlideShare is downloading. ×
0
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Document type definitions part 1
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Document type definitions part 1

777

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
777
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Document Type Definitions - Overview<br />XML<br />
  • 2. DTD stands for Document Type Definition<br />Allows an XML document to go further than meeting the requirements of being well-formed<br />Specifies requirements to be valid<br />A valid XML document matches definitions of allowable elements, attributes<br />DTD Overview<br />
  • 3. Validation can be done in code (i.e. using javascript, VB and DOM)<br />DTD’s allow use of a validating parser that compares the document against specifications<br />Typically makes application changes and maintenance easier<br />Less tied to a particular programming language/environment<br />Validation<br />
  • 4. Declarations are used to specify document requirements<br />Document type declaration<br />Element declaration<br />Attribute List declaration<br />Entity declaration<br />Declarations<br />
  • 5. Includes name of root element<br />Allows specification of where the DTD is located<br />DTD can be embedded in the XML file (local)<br />DTD can refer to external file, Uniform Resource Identifier (URI)<br />Local takes precedence over external<br />Document Type Declaration<br />
  • 6. Element Declaration has 3 parts:<br />Declaration<br />Element name<br />Element content<br />Element content can include a list of child elements or data<br />Element Declaration<br />
  • 7. DTD included in XML document<br />Definition of a student:<br /><!DOCTYPE student[<br /><!ELEMENT student(first, last, studentID)><br /><!ELEMENT first (#PCDATA)><br /><!ELEMENT last(#PCDATA)><br /><ELEMENT studentID(#PCDATA)><br />]><br />LocalDTD<br />Document Type Declaration<br />Element Declaration<br />A student element is made up of first name, last name, and student id elements<br />
  • 8. DTD exists in external file/location<br />Must use keyword to specify type of location<br />SYSTEM is a reference to local file system<br />PUBLIC is reference to DTD accessed through a catalog<br />Can use both together<br />If can’t find catalog reference can use specified file<br />External Definition<br />
  • 9. Reference in XML file:<br /><!DOCTYPE student SYSTEM “student.dtd”><br />External file:<br /><!ELEMENT student(first, last, studentID)><br /><!ELEMENT first (#PCDATA)><br /><!ELEMENT last(#PCDATA)><br /><ELEMENT studentID(#PCDATA)><br />]><br />Sample External Definition<br />Document Type Declaration<br />Element Declaration<br />
  • 10. Element name must match name in XML document<br />If using namespaces, prefixes must match<br />Content Model defines what the element can store<br />An element<br />Mixed (i.e. data and element)<br />Empty<br />Any<br />Working With Elements<br />
  • 11. One element can contain another<br />Can specify the elements contained by sequence<br />Can specify the elements contained as a choice<br />Element Content<br />
  • 12. Error raised if an element is missing<br />Error raised if there are extra elements<br />Error raised if elements in a different order<br />For a student, our content must be in firstname, lastname, studentID order<br />If find an element “major”, error<br />If order varies, error<br />If missing first, last, or studentID, error<br />Content by Sequence<br />
  • 13. Can allow content to vary between elements<br />| (vertical bar or pipe) indicates OR<br />If add a Grade element to a student that can be a letter or percent:<br /><!ELEMENT grade (letter | percent)><br /><!ELEMENT letter (#PCDATA)><br /><!ELEMENT percent (#PCDATA)<br />Indicates that must have letter or percent element<br /> Content by Choice<br />
  • 14. A name may be a full name (first, middle, last) or just first and last:<br /><!ELEMENT name (fullName | (first, last))><br /><!ELEMENT fullName (first, middle, last)><br /><!ELEMENT first (#PCDATA)><br /><!ELEMENT middle (#PCDATA)><br /><!ELEMENT last (#PCDATA)><br />By Choice: Example<br />
  • 15. Allows combination of elements and parsed character data<br />Can include additional information within an element, eg. how to display<br />Rules:<br />Managed by using Choice (or)<br />PCDATA must appear first in list of elements<br />List cannot include inner content model (only simple elements)<br />If there are child elements, include * <br />* Indicates that may appear zero or more times<br />Mixed Content<br />
  • 16. If want to include emphasis with the letter grade<br />Data: <letter><em>4</em></letter><br />Declaration:<br /><!ELEMENT letter (#PCDATA | em)*><br />Describes a letter element as the content (pcdata) plus emphasis element<br />Mixed Content -2 <br />
  • 17. An element can be empty<br /><br /> (never has child, content)<br />Declaration includes EMPTY:<br /><!ELEMENT br EMPTY><br />Means that the element CANNOT contain content<br />Empty Content<br />
  • 18. An element can contain any kind of value (or be empty)<br />Any elements declared in the DTD can occur, any number of times<br />Only elements that are part of the DTD can be part of the document!<br />May be empty<br />May contain PCDATA<br />Least restrictive model<br />Any Content<br />

×