SlideShare a Scribd company logo
Document Type Definitions - OverviewXML
DTD stands for Document Type DefinitionAllows an XML document to go further than meeting the requirements of being well-formedSpecifies requirements to be validA valid XML document matches definitions of allowable elements, attributesDTD Overview
Validation can be done in code (i.e. using javascript, VB and DOM)DTD’s allow use of a validating parser that compares the document against specificationsTypically makes application changes and maintenance easierLess tied to a particular programming language/environmentValidation
Declarations are used to specify document requirementsDocument type declarationElement declarationAttribute List declarationEntity declarationDeclarations
Includes name of root elementAllows specification of where the DTD is locatedDTD can be embedded in the XML file (local)DTD can refer to external file, Uniform Resource Identifier (URI)Local takes precedence over externalDocument Type Declaration
Element Declaration has 3 parts:DeclarationElement nameElement contentElement content can include a list of child elements or dataElement Declaration
DTD included in XML documentDefinition of a student:<!DOCTYPE student[<!ELEMENT student(first, last, studentID)><!ELEMENT first (#PCDATA)><!ELEMENT last(#PCDATA)><ELEMENT studentID(#PCDATA)>]>LocalDTDDocument Type DeclarationElement DeclarationA student element is made up of first name, last name, and student id elements
DTD exists in external file/locationMust use keyword to specify type of locationSYSTEM is a reference to local file systemPUBLIC is reference to DTD accessed through a catalogCan use both togetherIf can’t find catalog reference can use specified fileExternal Definition
Reference in XML file:<!DOCTYPE student SYSTEM “student.dtd”>External file:<!ELEMENT student(first, last, studentID)><!ELEMENT first (#PCDATA)><!ELEMENT last(#PCDATA)><ELEMENT studentID(#PCDATA)>]>Sample External DefinitionDocument Type DeclarationElement Declaration
Element name must match name in XML documentIf using namespaces, prefixes must matchContent Model defines what the element can storeAn elementMixed (i.e. data and element)EmptyAnyWorking With Elements
One element can contain anotherCan specify the elements contained by sequenceCan specify the elements contained as a choiceElement Content
Error raised if an element is missingError raised if there are extra elementsError raised if elements in a different orderFor a student, our content must be in firstname, lastname, studentID orderIf find an element “major”, errorIf order varies, errorIf missing first, last, or studentID, errorContent by Sequence
Can allow content to vary between elements| (vertical bar or pipe) indicates ORIf  add a Grade element to a student that can be a letter or percent:<!ELEMENT grade (letter | percent)><!ELEMENT letter (#PCDATA)><!ELEMENT percent (#PCDATA)Indicates that must have letter or percent element  Content by Choice
A name may be a full name (first, middle, last) or just first and last:<!ELEMENT name (fullName | (first, last))><!ELEMENT fullName (first, middle, last)><!ELEMENT first (#PCDATA)><!ELEMENT middle (#PCDATA)><!ELEMENT last (#PCDATA)>By Choice: Example
Allows combination of elements and parsed character dataCan include additional information within an element, eg. how to displayRules:Managed by using Choice (or)PCDATA must appear first in list of elementsList cannot include inner content model (only simple elements)If there are child elements, include * * Indicates that may appear zero or more timesMixed Content
If want to include emphasis with the letter gradeData: <letter><em>4</em></letter>Declaration:<!ELEMENT letter (#PCDATA | em)*>Describes a letter element as the content (pcdata) plus emphasis elementMixed Content -2
An element can be empty<br /> (never has child, content)Declaration includes EMPTY:<!ELEMENT br EMPTY>Means that the element CANNOT contain contentEmpty Content
An element can contain any kind of value (or be empty)Any elements declared in the DTD can occur, any number of timesOnly elements that are part of the DTD can be part of the document!May be emptyMay contain PCDATALeast restrictive modelAny Content
Ad

More Related Content

What's hot (20)

2 dtd - validating xml documents
2   dtd - validating xml documents2   dtd - validating xml documents
2 dtd - validating xml documents
gauravashq
 
Xml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyXml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web Technology
Rajan Shah
 
Jungahan web presentation
Jungahan web presentationJungahan web presentation
Jungahan web presentation
garden8an
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
yht4ever
 
Dtd
DtdDtd
Dtd
vikram singh
 
Xml dtd
Xml dtdXml dtd
Xml dtd
sana mateen
 
DTD
DTDDTD
DTD
Kumar
 
01 xml document structure
01 xml document structure01 xml document structure
01 xml document structure
Baskarkncet
 
Xml by Luqman
Xml by LuqmanXml by Luqman
Xml by Luqman
Luqman Shareef
 
Difference between dtd and xsd
Difference between dtd and xsdDifference between dtd and xsd
Difference between dtd and xsd
Umar Ali
 
XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
videde_group
 
XML Schema
XML SchemaXML Schema
XML Schema
yht4ever
 
Xml2
Xml2Xml2
Xml2
Abhishek Kesharwani
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
Sudharsan S
 
Xml Java
Xml JavaXml Java
Xml Java
cbee48
 
XML Introduction
XML IntroductionXML Introduction
XML Introduction
Bikash chhetri
 
SQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML DataSQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML Data
Marek Maśko
 
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
Xml For Dummies   Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...Xml For Dummies   Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
phanleson
 
Xml2
Xml2Xml2
Xml2
Abhishek Kesharwani
 
XML
XMLXML
XML
Prabu U
 
2 dtd - validating xml documents
2   dtd - validating xml documents2   dtd - validating xml documents
2 dtd - validating xml documents
gauravashq
 
Xml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyXml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web Technology
Rajan Shah
 
Jungahan web presentation
Jungahan web presentationJungahan web presentation
Jungahan web presentation
garden8an
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
yht4ever
 
01 xml document structure
01 xml document structure01 xml document structure
01 xml document structure
Baskarkncet
 
Difference between dtd and xsd
Difference between dtd and xsdDifference between dtd and xsd
Difference between dtd and xsd
Umar Ali
 
XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
videde_group
 
XML Schema
XML SchemaXML Schema
XML Schema
yht4ever
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
Sudharsan S
 
Xml Java
Xml JavaXml Java
Xml Java
cbee48
 
SQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML DataSQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML Data
Marek Maśko
 
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
Xml For Dummies   Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...Xml For Dummies   Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
phanleson
 

Similar to Document type definitions part 1 (20)

CIS-189 Final Review
CIS-189 Final ReviewCIS-189 Final Review
CIS-189 Final Review
Randy Riness @ South Puget Sound Community College
 
2-DTD.ppt
2-DTD.ppt2-DTD.ppt
2-DTD.ppt
KGSCSEPSGCT
 
Well Formed XML
Well Formed XMLWell Formed XML
Well Formed XML
Randy Riness @ South Puget Sound Community College
 
it8074-soa-uniti-.pdf
it8074-soa-uniti-.pdfit8074-soa-uniti-.pdf
it8074-soa-uniti-.pdf
FreeFire293813
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
RevathiAPICSE
 
uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2
Abhishek Kesharwani
 
Document type definitions part 2
Document type definitions part 2Document type definitions part 2
Document type definitions part 2
Randy Riness @ South Puget Sound Community College
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
smitha273566
 
XML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITIONXML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITION
SaraswathiRamalingam
 
Xml 1
Xml 1Xml 1
Xml 1
pavishkumarsingh
 
Xml and Co.
Xml and Co.Xml and Co.
Xml and Co.
Findik Dervis
 
Chen test paper20abcdeftfdfd
Chen test paper20abcdeftfdfdChen test paper20abcdeftfdfd
Chen test paper20abcdeftfdfd
techweb08
 
Test for an issue
Test for an issueTest for an issue
Test for an issue
techweb08
 
Chen's first test slides
Chen's first test slidesChen's first test slides
Chen's first test slides
Hima Challa
 
Xml
XmlXml
Xml
soumya
 
Xml11
Xml11Xml11
Xml11
Sudharsan S
 
Xml part2
Xml part2Xml part2
Xml part2
NOHA AW
 
II UNIT PPT NOTES.pdf this is the data structures
II UNIT PPT NOTES.pdf this is the data structuresII UNIT PPT NOTES.pdf this is the data structures
II UNIT PPT NOTES.pdf this is the data structures
PriyankaRamavath3
 
Xml
XmlXml
Xml
sudhakar mandal
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
smitha273566
 
Ad

More from Randy Riness @ South Puget Sound Community College (20)

Stored procedures
Stored proceduresStored procedures
Stored procedures
Randy Riness @ South Puget Sound Community College
 
3 sql overview
3 sql overview3 sql overview
3 sql overview
Randy Riness @ South Puget Sound Community College
 
Normalization
NormalizationNormalization
Normalization
Randy Riness @ South Puget Sound Community College
 
CIS160 final review
CIS160 final reviewCIS160 final review
CIS160 final review
Randy Riness @ South Puget Sound Community College
 
SQL Constraints
SQL ConstraintsSQL Constraints
SQL Constraints
Randy Riness @ South Puget Sound Community College
 
CIS 245 Final Review
CIS 245 Final ReviewCIS 245 Final Review
CIS 245 Final Review
Randy Riness @ South Puget Sound Community College
 
CIS145 Final Review
CIS145 Final ReviewCIS145 Final Review
CIS145 Final Review
Randy Riness @ South Puget Sound Community College
 
Cis166 Final Review C#
Cis166 Final Review C#Cis166 Final Review C#
Cis166 Final Review C#
Randy Riness @ South Puget Sound Community College
 
CIS245 sql
CIS245 sqlCIS245 sql
CIS245 sql
Randy Riness @ South Puget Sound Community College
 
Cis245 Midterm Review
Cis245 Midterm ReviewCis245 Midterm Review
Cis245 Midterm Review
Randy Riness @ South Puget Sound Community College
 
CSS
CSSCSS
CSS
Randy Riness @ South Puget Sound Community College
 
XPath
XPathXPath
XPath
Randy Riness @ South Puget Sound Community College
 
XSLT Overview
XSLT OverviewXSLT Overview
XSLT Overview
Randy Riness @ South Puget Sound Community College
 
Views
ViewsViews
Views
Randy Riness @ South Puget Sound Community College
 
CIS282 Midterm review
CIS282 Midterm reviewCIS282 Midterm review
CIS282 Midterm review
Randy Riness @ South Puget Sound Community College
 
Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
Schemas 2 - Restricting Values
Randy Riness @ South Puget Sound Community College
 
CIS 145 test 1 review
CIS 145 test 1 reviewCIS 145 test 1 review
CIS 145 test 1 review
Randy Riness @ South Puget Sound Community College
 
XML schemas
XML schemasXML schemas
XML schemas
Randy Riness @ South Puget Sound Community College
 
DOM specifics
DOM specificsDOM specifics
DOM specifics
Randy Riness @ South Puget Sound Community College
 
Ad

Recently uploaded (20)

Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 

Document type definitions part 1

  • 2. DTD stands for Document Type DefinitionAllows an XML document to go further than meeting the requirements of being well-formedSpecifies requirements to be validA valid XML document matches definitions of allowable elements, attributesDTD Overview
  • 3. Validation can be done in code (i.e. using javascript, VB and DOM)DTD’s allow use of a validating parser that compares the document against specificationsTypically makes application changes and maintenance easierLess tied to a particular programming language/environmentValidation
  • 4. Declarations are used to specify document requirementsDocument type declarationElement declarationAttribute List declarationEntity declarationDeclarations
  • 5. Includes name of root elementAllows specification of where the DTD is locatedDTD can be embedded in the XML file (local)DTD can refer to external file, Uniform Resource Identifier (URI)Local takes precedence over externalDocument Type Declaration
  • 6. Element Declaration has 3 parts:DeclarationElement nameElement contentElement content can include a list of child elements or dataElement Declaration
  • 7. DTD included in XML documentDefinition of a student:<!DOCTYPE student[<!ELEMENT student(first, last, studentID)><!ELEMENT first (#PCDATA)><!ELEMENT last(#PCDATA)><ELEMENT studentID(#PCDATA)>]>LocalDTDDocument Type DeclarationElement DeclarationA student element is made up of first name, last name, and student id elements
  • 8. DTD exists in external file/locationMust use keyword to specify type of locationSYSTEM is a reference to local file systemPUBLIC is reference to DTD accessed through a catalogCan use both togetherIf can’t find catalog reference can use specified fileExternal Definition
  • 9. Reference in XML file:<!DOCTYPE student SYSTEM “student.dtd”>External file:<!ELEMENT student(first, last, studentID)><!ELEMENT first (#PCDATA)><!ELEMENT last(#PCDATA)><ELEMENT studentID(#PCDATA)>]>Sample External DefinitionDocument Type DeclarationElement Declaration
  • 10. Element name must match name in XML documentIf using namespaces, prefixes must matchContent Model defines what the element can storeAn elementMixed (i.e. data and element)EmptyAnyWorking With Elements
  • 11. One element can contain anotherCan specify the elements contained by sequenceCan specify the elements contained as a choiceElement Content
  • 12. Error raised if an element is missingError raised if there are extra elementsError raised if elements in a different orderFor a student, our content must be in firstname, lastname, studentID orderIf find an element “major”, errorIf order varies, errorIf missing first, last, or studentID, errorContent by Sequence
  • 13. Can allow content to vary between elements| (vertical bar or pipe) indicates ORIf add a Grade element to a student that can be a letter or percent:<!ELEMENT grade (letter | percent)><!ELEMENT letter (#PCDATA)><!ELEMENT percent (#PCDATA)Indicates that must have letter or percent element Content by Choice
  • 14. A name may be a full name (first, middle, last) or just first and last:<!ELEMENT name (fullName | (first, last))><!ELEMENT fullName (first, middle, last)><!ELEMENT first (#PCDATA)><!ELEMENT middle (#PCDATA)><!ELEMENT last (#PCDATA)>By Choice: Example
  • 15. Allows combination of elements and parsed character dataCan include additional information within an element, eg. how to displayRules:Managed by using Choice (or)PCDATA must appear first in list of elementsList cannot include inner content model (only simple elements)If there are child elements, include * * Indicates that may appear zero or more timesMixed Content
  • 16. If want to include emphasis with the letter gradeData: <letter><em>4</em></letter>Declaration:<!ELEMENT letter (#PCDATA | em)*>Describes a letter element as the content (pcdata) plus emphasis elementMixed Content -2
  • 17. An element can be empty<br /> (never has child, content)Declaration includes EMPTY:<!ELEMENT br EMPTY>Means that the element CANNOT contain contentEmpty Content
  • 18. An element can contain any kind of value (or be empty)Any elements declared in the DTD can occur, any number of timesOnly elements that are part of the DTD can be part of the document!May be emptyMay contain PCDATALeast restrictive modelAny Content
  翻译: