SlideShare a Scribd company logo
1 of 49
Unit 2
XML DTD and Schema
Well formed and valid document
• a valid XML document is a more strict form of
a well-formed XML document .
• well formed if it follows all the preceding syntax rules of XML.
• valid XML documents can improve the quality of document processes.
DTD
• Document type definition.
• Defines a set of rules for an XML document to make it valid.
• Validated & verified using DTD.
• It will define the element like
Optional
No.of times it can occur
Attributes in it
DTD
• Advantage: single DTD can be referenced by many XML documents.
• Types:
Internal
External
Internal DTD
External DTD
Document not valid
Example
<?xml version=“1.0”?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to> tove</to>
<from>jani</from>
<heading>remainder</heading>
<body> weekend</body>
</note>
Structure of DTD
• Syntax:
Exclamation mark
DOCTYPE
Root element
SYSTEM|PUBLIC
Internal DTD elements
Internal and External DTD
DTD elements
• Syntax:
• ELEMENT
• Elementname
• Rule
• Elements are processed from top down(order of appearance).
contactlist.xml
contactlist.dtd
DTD Element rules
• Content rule
• ANY rule
• Empty rule
• #PCDATA rule
• Structure rule
• Element only rule
• Mixed rule
ANY rule
• Element may contain other elements and/or normal character data.
• Syntax:
• Example:
EMPTY rule
• Element contain no data
• Syntax:
• Can contain attributes.
• In HTML, image tag<img> doesn't contain any data nut it has
attributes the describes the location, height,..
• Empty elements can contain diagnostic information for the proessing
of data.
#PCDATA rule
• Indicated that parsed character data will be contained in the element.
• Syntax:
• Example:
• Example for CDATA:
Element-only rule
• Specifies that only elements may appear as children of the current
element.
• If there are to be options for which elements will appear, the listed
elements should be separated by the pipe(|) symbol.
Mixed rule
• Elements that may have both character data and child elements in
the data they contain.
• Options will be separated by the pipe symbol(|).
• Sequential lists will be separated by commas.
• Asterisk symbol(*)
Example
Element symbols
• * -<!ELEMENT children (name*)>
• , -<!ELEMENT address (street, city, state, zip)>
• []() -<!ELEMENT address (street, city, (state |province), zip)>
• | -<!ELEMENT dessert (cake | pie)>
• + - <!ELEMENT appliances (refrigerator+)>
• ? -<!ELEMENT employment (company?)>
• No symbol
Example
Example
DTD attributes
• Metadata to describe XML element.
• Syntax:
<!ATTLIST elementname attributename type defaultbehavior
defaultvalue>
• Eg:<name sex=”male” age=”30” race=”Caucasian”>Michael
Qualls</name>
• <!ATTLIST name
sex CDATA #REQUIRED
age CDATA #IMPLIED
race CDATA #IMPLIED >
Attributes types
1. CDATA: <ATTLIST box height CDATA ”0”>
2. ENTITY:<!ATTLIST img src ENTITY #REQUIRED>
3. ENTITIES:<!ATTLIST imgs srcs ENTITIES #REQUIRED>
4. ID: <!ATTLIST cog serial ID #REQUIRED>
5. IDREF:<!ATTLIST person cousin IDREF #IMPLIED>
6. IDREFS: <!ATTLIST person cousins IDREFS #IMPLIED>
Attribute types
7. NMTOKEN: <!ATTLIST address country NMTOKEN “usa”>
8. NMTOKENS: <!ATTLIST region states NMTOKENS “KS OK” >
9. NOTATION: <!ATTLIST music play NOTATION “mplayer2.exe “>
10. ENUMERATED: <!ATTLIST college grad (1|0) “1”>
Default value types
• #REQUIRED:<!ATTLIST season year CDATA #REQUIRED >
• #IMPLIED:<!ATTLIST field size CDATA #IMPLIED >
• #FIXED:<!ATTLIST bcc hidden #FIXED “true” >
• Default :<!ATTLIST children number CDATA “0”>
DTD Entities
• Storage units.
• well-formed XML, normal text, binary data, a database record, and so
on.
• Syntax:
<!ENTITY entityname [SYSTEM | PUBLIC] entitycontent>
Internal Entity
<?xml version=”1.0”?>
<!DOCTYPE library [
<!ENTITY cpy “Copyright 2000”>
<!ELEMENT library (book+)>
<!ELEMENT book (title,author,copyright)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT copyright (#PCDATA)>
]>
<library>
<book>
<title>How to Win Friends</title>
<author>Joe Charisma</author>
<copyright>&cpy;</copyright>
</book>
<book>
<title>Make Money Fast</title>
<author>Jimmy QuickBuck</author>
<copyright>&cpy;</copyright>
</book>
</library>
Predefined entities
Entity Content
&amp; &
&lt; <
&gt; >
&quot; “
&apos; ‘
Example
<icecream>
<flavor>Cherry Garcia</flavor>
<vendor>Ben &amp; Jerry’s</vendor>
</icecream>
External entity
<?xml version=”1.0”?>
<!DOCTYPE employees [
<!ENTITY bob SYSTEM “http://srvr/emps/bob.xml”>
<!ENTITY nancy SYSTEM “http://srvr/emps/nancy.xml”>
<!ELEMENT employees (clerk)>
<!ELEMENT clerk (#PCDATA)>
]>
<employees>
<clerk>&bob;</clerk>
<clerk>&nancy;</clerk>
</employees>
Non-text entity and notation
• Example: <!ENTITY myimage SYSTEM “myimage.gif” NDATA gif>
• Notation syntax:
<!NOTATION notationname [SYSTEM | PUBLIC ] dataformat>
External non-text entities
<!NOTATION gif SYSTEM “image/gif” >
<!ENTITY employeephoto SYSTEM “images/employees/MichaelQ.gif”
NDATA gif >
<!ELEMENT employee (name, sex, title, years) >
<!ATTLIST employee pic ENTITY #IMPLIED >
…
<employee pic=”employeephoto”>
…
</employee>
Parameter entities
• Syntax: <!ENTITY % entityname entitycontent>
• Example:
<!ENTITY % pc “(#PCDATA)”>
<!ELEMENT name %pc;>
<!ELEMENT age %pc;>
<!ELEMENT weight %pc;>
Drawbacks of DTD
• Composed of non-XML syntax.
• Single DTD per document.
• Not object oriented.
• Don’t support namespace.
• Weak data typing.
XML Schema Elements
• All
• Any
• anyAttribute
• Annotation
• Appinfo
• Attribute
• attributeGroup
• Choice
• complexContent
• complexType
• Documentation
• Element
• Extension
• Field
• Group
• Import
• Include
• Key
• Keyref
• List
• Notation
• Redefine
• Restrictions
• Schema
• Selector
• Sequence
• simpleContent
• simpleType
• Union
• Unique
Declaring Attribute
<xsd:complexType name=”ProductType”>
<xsd:attribute name=”Name” type=”xsd:string”/>
<xsd:attribute name=”Id” type=”xsd:positiveInteger”/>
<xsd:attribute name=”Price”>
<xsd:simpleType>
<xsd:restriction base=”xsd:decimal”>
<xsd:fractionDigits value=”2”/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name=”Quantity” type=”xsd:positiveInteger”/>
</xsd:complexType>
Data types
• anyURI
• base64Binary
• Boolean
• Byte
• Date
• dateTime
• Decimal
• Double
• duration
• ENTITIES
• ENTITY
• Float
• gDay
• gMonth
• gMonthDay
• gYear
• gYearMonth
• hexBinary
• ID
• IDREF
• IDREFS
• Int
• Integer
• Language
• Long
• Name
• NCName
• Negative Integer
• NMToken
• NMTOKENS
• Nonnegative integer
• Nonpositive integer
• Normalized string
• NOTATION
• positiveInteger
• Qname
• Short
• String
• Time
• Token
• unsignedByte
• unsignedInt
• unsignedLong
• unsignedShort
• Primitive datatypes
• Derived datatypes
• Syntax:
<attribute name=”” type=”” [use=””] [fixed=””] [default=””] [ref=””]/>
• ‘use’ possible values:
Optional
Prohibited
Required
Declaring element
• Syntax:
<element name=”” [type=””] [abstract=””] [block=””]
➥[default=””] [final=””] [fixed=””] [minOccurs=””]
➥[maxOccurs=””] [nillable=””] [ref=””]
➥[substitutionGroup=””]/>
• Block: all, extension, restriction, substitution.
Declaring Complex Elements
• Syntax:
<xsd:complexType name=’’ [abstract=’’] [base=’’] [block=’’]
➥[final=’’] [mixed=’’]/>
• Block: all, extension, restriction.
• A <complexType>element in the XML Schema Definition Language
may contain only one of the following elements:
all, choice, complexContent, group, sequence, simpleContent.
Declaring Simple Elements
• Syntax:
<xsd:simpleType name=’’>
<xsd:restriction base=’’/>
</xsd:simpleType>

More Related Content

What's hot (20)

Xml schema
Xml schemaXml schema
Xml schema
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Types of Selectors (HTML)
Types of Selectors (HTML)Types of Selectors (HTML)
Types of Selectors (HTML)
 
Xml
XmlXml
Xml
 
Css tables
Css tablesCss tables
Css tables
 
XML
XMLXML
XML
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Html
HtmlHtml
Html
 
XSLT
XSLTXSLT
XSLT
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Php string function
Php string function Php string function
Php string function
 
Introduction to XHTML
Introduction to XHTMLIntroduction to XHTML
Introduction to XHTML
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Xml presentation
Xml presentationXml presentation
Xml presentation
 
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
 
jQuery
jQueryjQuery
jQuery
 
Functions in javascript
Functions in javascriptFunctions in javascript
Functions in javascript
 
How to Create an Array & types in PHP
How to Create an Array & types in PHP How to Create an Array & types in PHP
How to Create an Array & types in PHP
 
Html Intro2
Html Intro2Html Intro2
Html Intro2
 

Similar to XML DTD and Schema

Xml 20111006 hurd
Xml 20111006 hurdXml 20111006 hurd
Xml 20111006 hurdcarishurd
 
XML Schema
XML SchemaXML Schema
XML SchemaKumar
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD OverviewPradeep Rapolu
 
INTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptxINTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptxSarthakrOkr
 
Hyper Text Markup Language - Presentation.pptx
Hyper Text Markup Language - Presentation.pptxHyper Text Markup Language - Presentation.pptx
Hyper Text Markup Language - Presentation.pptxvanajaanbarasu
 
[Km] [wp] [3] [assignment]
[Km] [wp] [3] [assignment][Km] [wp] [3] [assignment]
[Km] [wp] [3] [assignment]Azam Charaniya
 
vtu HTML+Course+Slide cse notes and .pdf
vtu HTML+Course+Slide cse notes and .pdfvtu HTML+Course+Slide cse notes and .pdf
vtu HTML+Course+Slide cse notes and .pdfNaveenBhajantri1
 
web-lab2 for computer science html tss css java
web-lab2 for computer science html tss css javaweb-lab2 for computer science html tss css java
web-lab2 for computer science html tss css javashereifhany
 
IT2255 Web Essentials - Unit II Web Designing
IT2255 Web Essentials - Unit II  Web DesigningIT2255 Web Essentials - Unit II  Web Designing
IT2255 Web Essentials - Unit II Web Designingpkaviya
 
Xml part2
Xml part2Xml part2
Xml part2NOHA AW
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XMLMaung Nyunt
 

Similar to XML DTD and Schema (20)

It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
 
it8074-soa-uniti-.pdf
it8074-soa-uniti-.pdfit8074-soa-uniti-.pdf
it8074-soa-uniti-.pdf
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
Xml 20111006 hurd
Xml 20111006 hurdXml 20111006 hurd
Xml 20111006 hurd
 
2-DTD.ppt
2-DTD.ppt2-DTD.ppt
2-DTD.ppt
 
XML Schema
XML SchemaXML Schema
XML Schema
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
INTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptxINTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptx
 
Hyper Text Markup Language - Presentation.pptx
Hyper Text Markup Language - Presentation.pptxHyper Text Markup Language - Presentation.pptx
Hyper Text Markup Language - Presentation.pptx
 
[Km] [wp] [3] [assignment]
[Km] [wp] [3] [assignment][Km] [wp] [3] [assignment]
[Km] [wp] [3] [assignment]
 
XML Prep
XML PrepXML Prep
XML Prep
 
vtu HTML+Course+Slide cse notes and .pdf
vtu HTML+Course+Slide cse notes and .pdfvtu HTML+Course+Slide cse notes and .pdf
vtu HTML+Course+Slide cse notes and .pdf
 
XML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITIONXML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITION
 
web-lab2 for computer science html tss css java
web-lab2 for computer science html tss css javaweb-lab2 for computer science html tss css java
web-lab2 for computer science html tss css java
 
IT2255 Web Essentials - Unit II Web Designing
IT2255 Web Essentials - Unit II  Web DesigningIT2255 Web Essentials - Unit II  Web Designing
IT2255 Web Essentials - Unit II Web Designing
 
Xml part2
Xml part2Xml part2
Xml part2
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 

More from hamsa nandhini

SOA - Unit 5 - SOA and Business Process Management
SOA - Unit   5 - SOA and Business Process ManagementSOA - Unit   5 - SOA and Business Process Management
SOA - Unit 5 - SOA and Business Process Managementhamsa nandhini
 
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
SOA - Unit   4 - SOA & Web Services for integration and Multi-Channel accessSOA - Unit   4 - SOA & Web Services for integration and Multi-Channel access
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel accesshamsa nandhini
 
SOA - Unit 3 - SOA and Web Services
SOA - Unit   3 - SOA and Web ServicesSOA - Unit   3 - SOA and Web Services
SOA - Unit 3 - SOA and Web Serviceshamsa nandhini
 
SOA - Unit 2 - Service Oriented Architecture
SOA - Unit   2 - Service Oriented ArchitectureSOA - Unit   2 - Service Oriented Architecture
SOA - Unit 2 - Service Oriented Architecturehamsa nandhini
 
SOA - Unit 1 - Introduction to SOA with Web Services
SOA - Unit   1 - Introduction to SOA with Web ServicesSOA - Unit   1 - Introduction to SOA with Web Services
SOA - Unit 1 - Introduction to SOA with Web Serviceshamsa nandhini
 
NP - Unit 5 - Bootstrap, Autoconfigurion and BGP
NP - Unit 5 - Bootstrap, Autoconfigurion and BGPNP - Unit 5 - Bootstrap, Autoconfigurion and BGP
NP - Unit 5 - Bootstrap, Autoconfigurion and BGPhamsa nandhini
 
NP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
NP - Unit 4 - Routing - RIP, OSPF and Internet MulticastingNP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
NP - Unit 4 - Routing - RIP, OSPF and Internet Multicastinghamsa nandhini
 
NP - Unit 3 - Forwarding Datagram and ICMP
NP - Unit 3 - Forwarding Datagram and ICMPNP - Unit 3 - Forwarding Datagram and ICMP
NP - Unit 3 - Forwarding Datagram and ICMPhamsa nandhini
 
NP - Unit 2 - Internet Addressing, ARP and RARP
NP - Unit 2 - Internet Addressing, ARP and RARP NP - Unit 2 - Internet Addressing, ARP and RARP
NP - Unit 2 - Internet Addressing, ARP and RARP hamsa nandhini
 
Web application, cookies and sessions
Web application, cookies and sessionsWeb application, cookies and sessions
Web application, cookies and sessionshamsa nandhini
 
Database design and error handling
Database design and error handlingDatabase design and error handling
Database design and error handlinghamsa nandhini
 
Introduction to MySQL in PHP
Introduction to MySQL in PHPIntroduction to MySQL in PHP
Introduction to MySQL in PHPhamsa nandhini
 

More from hamsa nandhini (19)

SOA - Unit 5 - SOA and Business Process Management
SOA - Unit   5 - SOA and Business Process ManagementSOA - Unit   5 - SOA and Business Process Management
SOA - Unit 5 - SOA and Business Process Management
 
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
SOA - Unit   4 - SOA & Web Services for integration and Multi-Channel accessSOA - Unit   4 - SOA & Web Services for integration and Multi-Channel access
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
 
SOA - Unit 3 - SOA and Web Services
SOA - Unit   3 - SOA and Web ServicesSOA - Unit   3 - SOA and Web Services
SOA - Unit 3 - SOA and Web Services
 
SOA - Unit 2 - Service Oriented Architecture
SOA - Unit   2 - Service Oriented ArchitectureSOA - Unit   2 - Service Oriented Architecture
SOA - Unit 2 - Service Oriented Architecture
 
SOA - Unit 1 - Introduction to SOA with Web Services
SOA - Unit   1 - Introduction to SOA with Web ServicesSOA - Unit   1 - Introduction to SOA with Web Services
SOA - Unit 1 - Introduction to SOA with Web Services
 
NP - Unit 5 - Bootstrap, Autoconfigurion and BGP
NP - Unit 5 - Bootstrap, Autoconfigurion and BGPNP - Unit 5 - Bootstrap, Autoconfigurion and BGP
NP - Unit 5 - Bootstrap, Autoconfigurion and BGP
 
NP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
NP - Unit 4 - Routing - RIP, OSPF and Internet MulticastingNP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
NP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
 
NP - Unit 3 - Forwarding Datagram and ICMP
NP - Unit 3 - Forwarding Datagram and ICMPNP - Unit 3 - Forwarding Datagram and ICMP
NP - Unit 3 - Forwarding Datagram and ICMP
 
NP - Unit 2 - Internet Addressing, ARP and RARP
NP - Unit 2 - Internet Addressing, ARP and RARP NP - Unit 2 - Internet Addressing, ARP and RARP
NP - Unit 2 - Internet Addressing, ARP and RARP
 
Unit 1
Unit 1Unit 1
Unit 1
 
Web application, cookies and sessions
Web application, cookies and sessionsWeb application, cookies and sessions
Web application, cookies and sessions
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
 
Database design and error handling
Database design and error handlingDatabase design and error handling
Database design and error handling
 
Introduction to MySQL in PHP
Introduction to MySQL in PHPIntroduction to MySQL in PHP
Introduction to MySQL in PHP
 
Basics of PHP
Basics of PHPBasics of PHP
Basics of PHP
 
XML Security
XML SecurityXML Security
XML Security
 
SOAP and Web services
SOAP and Web servicesSOAP and Web services
SOAP and Web services
 
XML Technologies
XML TechnologiesXML Technologies
XML Technologies
 
fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
 

Recently uploaded

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

XML DTD and Schema

  • 1. Unit 2 XML DTD and Schema
  • 2. Well formed and valid document • a valid XML document is a more strict form of a well-formed XML document . • well formed if it follows all the preceding syntax rules of XML. • valid XML documents can improve the quality of document processes.
  • 3. DTD • Document type definition. • Defines a set of rules for an XML document to make it valid. • Validated & verified using DTD. • It will define the element like Optional No.of times it can occur Attributes in it
  • 4. DTD • Advantage: single DTD can be referenced by many XML documents. • Types: Internal External
  • 8. Example <?xml version=“1.0”?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> <note> <to> tove</to> <from>jani</from> <heading>remainder</heading> <body> weekend</body> </note>
  • 9. Structure of DTD • Syntax: Exclamation mark DOCTYPE Root element SYSTEM|PUBLIC Internal DTD elements
  • 11. DTD elements • Syntax: • ELEMENT • Elementname • Rule • Elements are processed from top down(order of appearance).
  • 14. DTD Element rules • Content rule • ANY rule • Empty rule • #PCDATA rule • Structure rule • Element only rule • Mixed rule
  • 15. ANY rule • Element may contain other elements and/or normal character data. • Syntax: • Example:
  • 16. EMPTY rule • Element contain no data • Syntax: • Can contain attributes. • In HTML, image tag<img> doesn't contain any data nut it has attributes the describes the location, height,.. • Empty elements can contain diagnostic information for the proessing of data.
  • 17. #PCDATA rule • Indicated that parsed character data will be contained in the element. • Syntax: • Example: • Example for CDATA:
  • 18. Element-only rule • Specifies that only elements may appear as children of the current element. • If there are to be options for which elements will appear, the listed elements should be separated by the pipe(|) symbol.
  • 19. Mixed rule • Elements that may have both character data and child elements in the data they contain. • Options will be separated by the pipe symbol(|). • Sequential lists will be separated by commas. • Asterisk symbol(*)
  • 21. Element symbols • * -<!ELEMENT children (name*)> • , -<!ELEMENT address (street, city, state, zip)> • []() -<!ELEMENT address (street, city, (state |province), zip)> • | -<!ELEMENT dessert (cake | pie)> • + - <!ELEMENT appliances (refrigerator+)> • ? -<!ELEMENT employment (company?)> • No symbol
  • 24. DTD attributes • Metadata to describe XML element. • Syntax: <!ATTLIST elementname attributename type defaultbehavior defaultvalue> • Eg:<name sex=”male” age=”30” race=”Caucasian”>Michael Qualls</name> • <!ATTLIST name sex CDATA #REQUIRED age CDATA #IMPLIED race CDATA #IMPLIED >
  • 25. Attributes types 1. CDATA: <ATTLIST box height CDATA ”0”> 2. ENTITY:<!ATTLIST img src ENTITY #REQUIRED> 3. ENTITIES:<!ATTLIST imgs srcs ENTITIES #REQUIRED> 4. ID: <!ATTLIST cog serial ID #REQUIRED> 5. IDREF:<!ATTLIST person cousin IDREF #IMPLIED> 6. IDREFS: <!ATTLIST person cousins IDREFS #IMPLIED>
  • 26. Attribute types 7. NMTOKEN: <!ATTLIST address country NMTOKEN “usa”> 8. NMTOKENS: <!ATTLIST region states NMTOKENS “KS OK” > 9. NOTATION: <!ATTLIST music play NOTATION “mplayer2.exe “> 10. ENUMERATED: <!ATTLIST college grad (1|0) “1”>
  • 27. Default value types • #REQUIRED:<!ATTLIST season year CDATA #REQUIRED > • #IMPLIED:<!ATTLIST field size CDATA #IMPLIED > • #FIXED:<!ATTLIST bcc hidden #FIXED “true” > • Default :<!ATTLIST children number CDATA “0”>
  • 28. DTD Entities • Storage units. • well-formed XML, normal text, binary data, a database record, and so on. • Syntax: <!ENTITY entityname [SYSTEM | PUBLIC] entitycontent>
  • 29. Internal Entity <?xml version=”1.0”?> <!DOCTYPE library [ <!ENTITY cpy “Copyright 2000”> <!ELEMENT library (book+)> <!ELEMENT book (title,author,copyright)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT copyright (#PCDATA)> ]>
  • 30. <library> <book> <title>How to Win Friends</title> <author>Joe Charisma</author> <copyright>&cpy;</copyright> </book> <book> <title>Make Money Fast</title> <author>Jimmy QuickBuck</author> <copyright>&cpy;</copyright> </book> </library>
  • 31. Predefined entities Entity Content &amp; & &lt; < &gt; > &quot; “ &apos; ‘
  • 33. External entity <?xml version=”1.0”?> <!DOCTYPE employees [ <!ENTITY bob SYSTEM “http://srvr/emps/bob.xml”> <!ENTITY nancy SYSTEM “http://srvr/emps/nancy.xml”> <!ELEMENT employees (clerk)> <!ELEMENT clerk (#PCDATA)> ]> <employees> <clerk>&bob;</clerk> <clerk>&nancy;</clerk> </employees>
  • 34. Non-text entity and notation • Example: <!ENTITY myimage SYSTEM “myimage.gif” NDATA gif> • Notation syntax: <!NOTATION notationname [SYSTEM | PUBLIC ] dataformat>
  • 35. External non-text entities <!NOTATION gif SYSTEM “image/gif” > <!ENTITY employeephoto SYSTEM “images/employees/MichaelQ.gif” NDATA gif > <!ELEMENT employee (name, sex, title, years) > <!ATTLIST employee pic ENTITY #IMPLIED > … <employee pic=”employeephoto”> … </employee>
  • 36. Parameter entities • Syntax: <!ENTITY % entityname entitycontent> • Example: <!ENTITY % pc “(#PCDATA)”> <!ELEMENT name %pc;> <!ELEMENT age %pc;> <!ELEMENT weight %pc;>
  • 37. Drawbacks of DTD • Composed of non-XML syntax. • Single DTD per document. • Not object oriented. • Don’t support namespace. • Weak data typing.
  • 38. XML Schema Elements • All • Any • anyAttribute • Annotation • Appinfo • Attribute • attributeGroup • Choice
  • 39. • complexContent • complexType • Documentation • Element • Extension • Field • Group • Import • Include • Key • Keyref • List
  • 40. • Notation • Redefine • Restrictions • Schema • Selector • Sequence • simpleContent • simpleType • Union • Unique
  • 41. Declaring Attribute <xsd:complexType name=”ProductType”> <xsd:attribute name=”Name” type=”xsd:string”/> <xsd:attribute name=”Id” type=”xsd:positiveInteger”/> <xsd:attribute name=”Price”> <xsd:simpleType> <xsd:restriction base=”xsd:decimal”> <xsd:fractionDigits value=”2”/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name=”Quantity” type=”xsd:positiveInteger”/> </xsd:complexType>
  • 42. Data types • anyURI • base64Binary • Boolean • Byte • Date • dateTime • Decimal • Double • duration
  • 43. • ENTITIES • ENTITY • Float • gDay • gMonth • gMonthDay • gYear • gYearMonth • hexBinary • ID • IDREF • IDREFS
  • 44. • Int • Integer • Language • Long • Name • NCName • Negative Integer • NMToken • NMTOKENS • Nonnegative integer • Nonpositive integer • Normalized string
  • 45. • NOTATION • positiveInteger • Qname • Short • String • Time • Token • unsignedByte • unsignedInt • unsignedLong • unsignedShort
  • 46. • Primitive datatypes • Derived datatypes • Syntax: <attribute name=”” type=”” [use=””] [fixed=””] [default=””] [ref=””]/> • ‘use’ possible values: Optional Prohibited Required
  • 47. Declaring element • Syntax: <element name=”” [type=””] [abstract=””] [block=””] ➥[default=””] [final=””] [fixed=””] [minOccurs=””] ➥[maxOccurs=””] [nillable=””] [ref=””] ➥[substitutionGroup=””]/> • Block: all, extension, restriction, substitution.
  • 48. Declaring Complex Elements • Syntax: <xsd:complexType name=’’ [abstract=’’] [base=’’] [block=’’] ➥[final=’’] [mixed=’’]/> • Block: all, extension, restriction. • A <complexType>element in the XML Schema Definition Language may contain only one of the following elements: all, choice, complexContent, group, sequence, simpleContent.
  • 49. Declaring Simple Elements • Syntax: <xsd:simpleType name=’’> <xsd:restriction base=’’/> </xsd:simpleType>