SlideShare a Scribd company logo
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>
Ad

More Related Content

What's hot (20)

CSS media types
CSS media typesCSS media types
CSS media types
Russ Weakley
 
Extensible Markup Language (XML)
Extensible Markup Language (XML)Extensible Markup Language (XML)
Extensible Markup Language (XML)
AakankshaR
 
Data Integration and Transformation in Data mining
Data Integration and Transformation in Data miningData Integration and Transformation in Data mining
Data Integration and Transformation in Data mining
kavitha muneeshwaran
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
WordPress Memphis
 
Sgml
SgmlSgml
Sgml
rahul kundu
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
yht4ever
 
XML Schema
XML SchemaXML Schema
XML Schema
Kumar
 
Html ppt
Html pptHtml ppt
Html ppt
Ruchi Kumari
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
Archit Saxena
 
10. XML in DBMS
10. XML in DBMS10. XML in DBMS
10. XML in DBMS
koolkampus
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
baabtra.com - No. 1 supplier of quality freshers
 
Php forms
Php formsPhp forms
Php forms
Anne Lee
 
Xml namespace
Xml namespaceXml namespace
Xml namespace
GayathriS578276
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHP
Nisa Soomro
 
Introduction to XHTML
Introduction to XHTMLIntroduction to XHTML
Introduction to XHTML
Hend Al-Khalifa
 
Css properties
Css propertiesCss properties
Css properties
Dr. SURESH KUMAR Krishnamoorthy
 
1.2 steps and functionalities
1.2 steps and functionalities1.2 steps and functionalities
1.2 steps and functionalities
Krish_ver2
 
XML
XMLXML
XML
Avanitrambadiya
 
CSS ppt
CSS pptCSS ppt
CSS ppt
Sanmuga Nathan
 

Similar to XML DTD and Schema (20)

It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
smitha273566
 
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
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
smitha273566
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
Return on Intelligence
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
Return on Intelligence
 
Xml 20111006 hurd
Xml 20111006 hurdXml 20111006 hurd
Xml 20111006 hurd
carishurd
 
2-DTD.ppt
2-DTD.ppt2-DTD.ppt
2-DTD.ppt
KGSCSEPSGCT
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
Pradeep Rapolu
 
INTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptxINTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptx
SarthakrOkr
 
Hyper Text Markup Language - Presentation.pptx
Hyper Text Markup Language - Presentation.pptxHyper Text Markup Language - Presentation.pptx
Hyper Text Markup Language - Presentation.pptx
vanajaanbarasu
 
[Km] [wp] [3] [assignment]
[Km] [wp] [3] [assignment][Km] [wp] [3] [assignment]
[Km] [wp] [3] [assignment]
Azam Charaniya
 
XML Prep
XML PrepXML Prep
XML Prep
Nitin Marwal
 
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
NaveenBhajantri1
 
XML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITIONXML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITION
SaraswathiRamalingam
 
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
shereifhany
 
web design technology- mark up languages
web design technology- mark up languagesweb design technology- mark up languages
web design technology- mark up languages
ssuser2efca7
 
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
pkaviya
 
Xml part2
Xml part2Xml part2
Xml part2
NOHA AW
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
Maung Nyunt
 
Xml 20111006 hurd
Xml 20111006 hurdXml 20111006 hurd
Xml 20111006 hurd
carishurd
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
Pradeep Rapolu
 
INTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptxINTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptx
SarthakrOkr
 
Hyper Text Markup Language - Presentation.pptx
Hyper Text Markup Language - Presentation.pptxHyper Text Markup Language - Presentation.pptx
Hyper Text Markup Language - Presentation.pptx
vanajaanbarasu
 
[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 .pdf
NaveenBhajantri1
 
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
shereifhany
 
web design technology- mark up languages
web design technology- mark up languagesweb design technology- mark up languages
web design technology- mark up languages
ssuser2efca7
 
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
pkaviya
 
Xml part2
Xml part2Xml part2
Xml part2
NOHA AW
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
Maung Nyunt
 
Ad

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
hamsa 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 access
hamsa 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 Services
hamsa nandhini
 
SOA - Unit 2 - Service Oriented Architecture
SOA - Unit   2 - Service Oriented ArchitectureSOA - Unit   2 - Service Oriented Architecture
SOA - Unit 2 - Service Oriented Architecture
hamsa 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 Services
hamsa 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 BGP
hamsa 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 Multicasting
hamsa 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 ICMP
hamsa 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
 
Unit 1
Unit 1Unit 1
Unit 1
hamsa nandhini
 
Web application, cookies and sessions
Web application, cookies and sessionsWeb application, cookies and sessions
Web application, cookies and sessions
hamsa nandhini
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
hamsa nandhini
 
Database design and error handling
Database design and error handlingDatabase design and error handling
Database design and error handling
hamsa nandhini
 
Introduction to MySQL in PHP
Introduction to MySQL in PHPIntroduction to MySQL in PHP
Introduction to MySQL in PHP
hamsa nandhini
 
Basics of PHP
Basics of PHPBasics of PHP
Basics of PHP
hamsa nandhini
 
XML Security
XML SecurityXML Security
XML Security
hamsa nandhini
 
SOAP and Web services
SOAP and Web servicesSOAP and Web services
SOAP and Web services
hamsa nandhini
 
XML Technologies
XML TechnologiesXML Technologies
XML Technologies
hamsa nandhini
 
fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
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 Management
hamsa 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 access
hamsa 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 Services
hamsa nandhini
 
SOA - Unit 2 - Service Oriented Architecture
SOA - Unit   2 - Service Oriented ArchitectureSOA - Unit   2 - Service Oriented Architecture
SOA - Unit 2 - Service Oriented Architecture
hamsa 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 Services
hamsa 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 BGP
hamsa 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 Multicasting
hamsa 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 ICMP
hamsa 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 sessions
hamsa nandhini
 
Database design and error handling
Database design and error handlingDatabase design and error handling
Database design and error handling
hamsa nandhini
 
Introduction to MySQL in PHP
Introduction to MySQL in PHPIntroduction to MySQL in PHP
Introduction to MySQL in PHP
hamsa nandhini
 
Ad

Recently uploaded (20)

Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 

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>