SlideShare a Scribd company logo
1 of 24
UNIT I INTRODUCTION TO XML
XML document structure – Well formed and valid
documents – Namespaces – DTD – XML Schema
– X-Files.
XML Document Structure
Including all sections of an XML document
helps to make for a well-structured XML document
XML Document Structure
• An XML document consists of a number of discrete components
• Not all the sections of an XML document may be necessary,
– But their inclusion helps to make for a well-structured XML document
• A well-structured XML document can
– Easily be transported between systems and devices
Major portions of an XML document
• The major portions of an XML document include the following:
– The XML declaration
– The Document Type Declaration (DTD)
– The element data
– The attribute data
– The character data or XML content
XML Declaration
• XML Declaration is a definite way of stating exactly
– What the document contains.
• XML document can optionally have an XML declaration
– It must be the first statement of the XML document
• XML declaration is a processing instruction of the form
<?xml ...?>
Components of XML Declaration
Component Meaning
<?xml Starts the beginning of the processing instruction
Version= “xxx” Describes the specific version of XML being used
standalone= “xxx” Defines whether documents are allowed to contain
external markup declarations
encoding= “xxx” Indicates the character encoding that the document uses.
The default is “US-ASCII” but can be set to any value
Example :
Document Type Declaration (DOCTYPE)
• DOCTYPE
– Gives a name to the XML content , and
– Provides a means to guarantee the document’s validity,
• Either by including or specifying a link to a Document Type Definition (DTD).
• DOCTYPE is optional in XML
• Valid XML documents must declare the document type to which they
comply
General Form of DOCTYPE
• General Forms of the Document Type Declarations
<!DOCTYPE NAME SYSTEM “file”>
<!DOCTYPE NAME [ ]>
<!DOCTYPE NAME SYSTEM “file” [ ]>
First form refers to
– A document that only allows use of an externally defined DTD subset.
Second declaration
– Only allows an internally defined subset within the document.
Last form provides
– A place for inclusion of an internally defined DTD subset b/w square brackets
while also making use of an external subset.
Example on DOCTYPE
• Example on First Forms
<!DOCTYPE shirt SYSTEM “shirt.dtd”>
– Root (first) tag in the document will be the <shirt> element
– DTD is saved to a file named shirt.dtd
Components of DOCTYPE
Markup and Content
• XML documents are composed of markup and content.
• In general, six kinds of markup can occur in an XML document:
– elements,
– entity references,
– comments,
– processing instructions,
– marked sections, and
– Document Type Declarations.
Elements
• XML elements are
– Either a matched pair of XML tags or single XML tags that are “self-closing.”
• For example,
– A shirt element begins with <shirt> and ends with </shirt>.
• When elements do not come in pairs,
– The element name is suffixed by the forward slash.
• The “unmatched” elements are known as empty elements
• Elements can be arbitrarily nested within other elements
Attributes
• Within elements,
Additional information can be communicated to XML processors
– That modifies the nature of the encapsulated content.
• Attributes are name/value pairs contained within the start element
– That can specify text strings that modify the context of the element.
• Example:
<price currency=”USD”>…</price>
<on_sale start_date=”10-15-2001”/>
Entity References
• Some characters have a special meaning in XML,
• Entity references indicate to XML-processing applications
– That a special text string is to follow that will be replaced with a different literal value,
• Entity references are delimited by
– An ampersand at the beginning and
– A semicolon at the ending.
• Ex : Inserting a > sign in our text
<descript> Following says 8 is greater than 5 </descript>
<equation>4 &gt; 5</equation>
Major Entity References Character
&lt; <
&gt; >
&amp; &
&quot; "
&apos; '
Comments
• Comments can be placed anywhere in a document and
– They are not considered to be part of the textual content of an XML document.
• Character sequence <!-- begins a comment and --> ends the comment.
• B/w these 2 delimiters,
– Any text at all can be written, including valid XML markup.
• Only restriction is that
– Comment delimiters cannot be used; neither can the literal string --.
• Example :
<!-- The below element talks about Elephant I once owned... -->
<animal>Elephant</animal>
Processing Instructions (PIs)
• PIs are not a textual part of an XML document
– But provide information to applications as to how the content should be processed.
• Unlike comments, XML processors are required to pass along PIs.
• Processing instructions have the following form:
<?instruction options?>
• Instruction name is called the PI target
– It is a special identifier that the processing application is intended to understand.
• Any following information can be optionally specified
• Example: <?send-message “process complete”?>
Marked CDATA Sections
• Some documents will contain a large number of characters and text
– That an XML processor should ignore and pass to an application.
• These are known as character data (or CDATA) sections.
• Within an XML document, a CDATA section instructs the parser
– To ignore all markup characters except the end of the CDATA markup instruction.
• This allows for a section of XML code to be “escaped”
– So that it doesn’t inadvertently disrupt XML processing.
• CDATA sections follow this general form:
<![CDATA[content]]>
Marked CDATA Sections
• All content contained in the CDATA section is
– Passed as string literals directly to the application without interpretation
• Example:
<object_code>
<![CDATA[
function master(poltice integer) {
if poltice<=3 then {
Mas=poltice+IntToString(FindElement(“<chicken>”));
}
}
]]>
</object_code>
Document Type Definitions (DTD)
• Don’t confuse the DOCTYPE with the DTD.
• A DOCTYPE and a DTD serve very different, although related purposes.
– DOCTYPE is used to identify and name the XML content
– DTD is used to validate the metadata contained within.
• DTDs represent a specific form of XML text
– That is allowable in an XML document.
• DTDs and XML Schema are the means for defining the validity constraints
on XML documents
XML Content
• XML content can consist of any data, including binary data,
– As long as it doesn’t violate rules that would confuse the content with valid XML
metadata instructions.
• XML content can contain any characters,
– Including any valid Unicode and international characters.
• XML content can be as long as necessary
XML document with an internal DTD
• A DTD defines the structure & the legal elements and attributes of an XML
document.
• An application can use a DTD to verify that XML data is valid.
• If the DTD is declared inside the XML file,
– It must be wrapped inside the <!DOCTYPE> definition.
• Document Type Declaration (DOCTYPE) gives a name to the XML
content
Document Type Declaration (DOCTYPE)
• A DTD defines the structure & the legal elements and attributes of an XML
document.
• An application can use a DTD to verify that XML data is valid.
• If the DTD is declared inside the XML file,
– It must be wrapped inside the <!DOCTYPE> definition.
• Document Type Declaration (DOCTYPE) gives a name to the XML
content
01 xml document structure

More Related Content

What's hot (20)

XML Document Object Model (DOM)
XML Document Object Model (DOM)XML Document Object Model (DOM)
XML Document Object Model (DOM)
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
 
Unit ii java script and xhtml documents and dynamic documents with javascript
Unit ii java script and xhtml documents and dynamic documents with javascriptUnit ii java script and xhtml documents and dynamic documents with javascript
Unit ii java script and xhtml documents and dynamic documents with javascript
 
XML-Extensible Markup Language
XML-Extensible Markup Language XML-Extensible Markup Language
XML-Extensible Markup Language
 
Dom
Dom Dom
Dom
 
Html forms
Html formsHtml forms
Html forms
 
XSLT
XSLTXSLT
XSLT
 
XML
XMLXML
XML
 
Json
JsonJson
Json
 
Web services SOAP
Web services SOAPWeb services SOAP
Web services SOAP
 
DTD
DTDDTD
DTD
 
XSLT.ppt
XSLT.pptXSLT.ppt
XSLT.ppt
 
XML and DTD
XML and DTDXML and DTD
XML and DTD
 
Xml
XmlXml
Xml
 
XML Databases
XML DatabasesXML Databases
XML Databases
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Xml parsers
Xml parsersXml parsers
Xml parsers
 
HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
 
Xml ppt
Xml pptXml ppt
Xml ppt
 

Similar to 01 xml document structure

Similar to 01 xml document structure (20)

M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5   XMLM.FLORENCE DAYANA WEB DESIGN -Unit 5   XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
 
Ch2 neworder
Ch2 neworderCh2 neworder
Ch2 neworder
 
1 xml fundamentals
1 xml fundamentals1 xml fundamentals
1 xml fundamentals
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 
XML-Unit 1.ppt
XML-Unit 1.pptXML-Unit 1.ppt
XML-Unit 1.ppt
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
chapter 4 web authoring unit 4 xml.pptx
chapter 4 web authoring  unit 4 xml.pptxchapter 4 web authoring  unit 4 xml.pptx
chapter 4 web authoring unit 4 xml.pptx
 
Web Technology Part 4
Web Technology Part 4Web Technology Part 4
Web Technology Part 4
 
IT6801-Service Oriented Architecture- UNIT-I notes
IT6801-Service Oriented Architecture- UNIT-I notesIT6801-Service Oriented Architecture- UNIT-I notes
IT6801-Service Oriented Architecture- UNIT-I notes
 
Xml 1
Xml 1Xml 1
Xml 1
 
XML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITIONXML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITION
 
Xml
XmlXml
Xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Web Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdfWeb Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdf
 
Xml basics
Xml basicsXml basics
Xml basics
 
Intro to xml
Intro to xmlIntro to xml
Intro to xml
 
Xml
XmlXml
Xml
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
WT UNIT-2 XML.pdf
WT UNIT-2 XML.pdfWT UNIT-2 XML.pdf
WT UNIT-2 XML.pdf
 

More from Baskarkncet

02 well formed and valid documents
02 well formed and valid documents02 well formed and valid documents
02 well formed and valid documentsBaskarkncet
 
11 deployment diagrams
11 deployment diagrams11 deployment diagrams
11 deployment diagramsBaskarkncet
 
10 component diagram
10 component diagram10 component diagram
10 component diagramBaskarkncet
 
09 package diagram
09 package diagram09 package diagram
09 package diagramBaskarkncet
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagramBaskarkncet
 
07 interaction diagrams
07 interaction diagrams07 interaction diagrams
07 interaction diagramsBaskarkncet
 
06 class diagrams
06 class diagrams06 class diagrams
06 class diagramsBaskarkncet
 
03 unified process
03 unified process03 unified process
03 unified processBaskarkncet
 

More from Baskarkncet (19)

Unit_I.pptx
Unit_I.pptxUnit_I.pptx
Unit_I.pptx
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Unit 1
Unit 1Unit 1
Unit 1
 
HCI
HCIHCI
HCI
 
03 x files
03 x files03 x files
03 x files
 
03 namespace
03 namespace03 namespace
03 namespace
 
02 well formed and valid documents
02 well formed and valid documents02 well formed and valid documents
02 well formed and valid documents
 
00 introduction
00 introduction00 introduction
00 introduction
 
11 deployment diagrams
11 deployment diagrams11 deployment diagrams
11 deployment diagrams
 
10 component diagram
10 component diagram10 component diagram
10 component diagram
 
09 package diagram
09 package diagram09 package diagram
09 package diagram
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagram
 
07 interaction diagrams
07 interaction diagrams07 interaction diagrams
07 interaction diagrams
 
06 class diagrams
06 class diagrams06 class diagrams
06 class diagrams
 
05 use case
05 use case05 use case
05 use case
 
03 unified process
03 unified process03 unified process
03 unified process
 
02 uml
02 uml02 uml
02 uml
 
04 uml diagrams
04 uml diagrams04 uml diagrams
04 uml diagrams
 
01 introduction
01 introduction01 introduction
01 introduction
 

Recently uploaded

Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming languageSmritiSharma901052
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodManicka Mamallan Andavar
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfDrew Moseley
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 

Recently uploaded (20)

Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming language
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument method
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdf
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 

01 xml document structure

  • 1. UNIT I INTRODUCTION TO XML XML document structure – Well formed and valid documents – Namespaces – DTD – XML Schema – X-Files.
  • 2. XML Document Structure Including all sections of an XML document helps to make for a well-structured XML document
  • 3. XML Document Structure • An XML document consists of a number of discrete components • Not all the sections of an XML document may be necessary, – But their inclusion helps to make for a well-structured XML document • A well-structured XML document can – Easily be transported between systems and devices
  • 4. Major portions of an XML document • The major portions of an XML document include the following: – The XML declaration – The Document Type Declaration (DTD) – The element data – The attribute data – The character data or XML content
  • 5. XML Declaration • XML Declaration is a definite way of stating exactly – What the document contains. • XML document can optionally have an XML declaration – It must be the first statement of the XML document • XML declaration is a processing instruction of the form <?xml ...?>
  • 6. Components of XML Declaration Component Meaning <?xml Starts the beginning of the processing instruction Version= “xxx” Describes the specific version of XML being used standalone= “xxx” Defines whether documents are allowed to contain external markup declarations encoding= “xxx” Indicates the character encoding that the document uses. The default is “US-ASCII” but can be set to any value Example :
  • 7. Document Type Declaration (DOCTYPE) • DOCTYPE – Gives a name to the XML content , and – Provides a means to guarantee the document’s validity, • Either by including or specifying a link to a Document Type Definition (DTD). • DOCTYPE is optional in XML • Valid XML documents must declare the document type to which they comply
  • 8. General Form of DOCTYPE • General Forms of the Document Type Declarations <!DOCTYPE NAME SYSTEM “file”> <!DOCTYPE NAME [ ]> <!DOCTYPE NAME SYSTEM “file” [ ]> First form refers to – A document that only allows use of an externally defined DTD subset. Second declaration – Only allows an internally defined subset within the document. Last form provides – A place for inclusion of an internally defined DTD subset b/w square brackets while also making use of an external subset.
  • 9. Example on DOCTYPE • Example on First Forms <!DOCTYPE shirt SYSTEM “shirt.dtd”> – Root (first) tag in the document will be the <shirt> element – DTD is saved to a file named shirt.dtd
  • 11. Markup and Content • XML documents are composed of markup and content. • In general, six kinds of markup can occur in an XML document: – elements, – entity references, – comments, – processing instructions, – marked sections, and – Document Type Declarations.
  • 12. Elements • XML elements are – Either a matched pair of XML tags or single XML tags that are “self-closing.” • For example, – A shirt element begins with <shirt> and ends with </shirt>. • When elements do not come in pairs, – The element name is suffixed by the forward slash. • The “unmatched” elements are known as empty elements • Elements can be arbitrarily nested within other elements
  • 13. Attributes • Within elements, Additional information can be communicated to XML processors – That modifies the nature of the encapsulated content. • Attributes are name/value pairs contained within the start element – That can specify text strings that modify the context of the element. • Example: <price currency=”USD”>…</price> <on_sale start_date=”10-15-2001”/>
  • 14. Entity References • Some characters have a special meaning in XML, • Entity references indicate to XML-processing applications – That a special text string is to follow that will be replaced with a different literal value, • Entity references are delimited by – An ampersand at the beginning and – A semicolon at the ending. • Ex : Inserting a > sign in our text <descript> Following says 8 is greater than 5 </descript> <equation>4 &gt; 5</equation> Major Entity References Character &lt; < &gt; > &amp; & &quot; " &apos; '
  • 15. Comments • Comments can be placed anywhere in a document and – They are not considered to be part of the textual content of an XML document. • Character sequence <!-- begins a comment and --> ends the comment. • B/w these 2 delimiters, – Any text at all can be written, including valid XML markup. • Only restriction is that – Comment delimiters cannot be used; neither can the literal string --. • Example : <!-- The below element talks about Elephant I once owned... --> <animal>Elephant</animal>
  • 16. Processing Instructions (PIs) • PIs are not a textual part of an XML document – But provide information to applications as to how the content should be processed. • Unlike comments, XML processors are required to pass along PIs. • Processing instructions have the following form: <?instruction options?> • Instruction name is called the PI target – It is a special identifier that the processing application is intended to understand. • Any following information can be optionally specified • Example: <?send-message “process complete”?>
  • 17. Marked CDATA Sections • Some documents will contain a large number of characters and text – That an XML processor should ignore and pass to an application. • These are known as character data (or CDATA) sections. • Within an XML document, a CDATA section instructs the parser – To ignore all markup characters except the end of the CDATA markup instruction. • This allows for a section of XML code to be “escaped” – So that it doesn’t inadvertently disrupt XML processing. • CDATA sections follow this general form: <![CDATA[content]]>
  • 18. Marked CDATA Sections • All content contained in the CDATA section is – Passed as string literals directly to the application without interpretation • Example: <object_code> <![CDATA[ function master(poltice integer) { if poltice<=3 then { Mas=poltice+IntToString(FindElement(“<chicken>”)); } } ]]> </object_code>
  • 19. Document Type Definitions (DTD) • Don’t confuse the DOCTYPE with the DTD. • A DOCTYPE and a DTD serve very different, although related purposes. – DOCTYPE is used to identify and name the XML content – DTD is used to validate the metadata contained within. • DTDs represent a specific form of XML text – That is allowable in an XML document. • DTDs and XML Schema are the means for defining the validity constraints on XML documents
  • 20. XML Content • XML content can consist of any data, including binary data, – As long as it doesn’t violate rules that would confuse the content with valid XML metadata instructions. • XML content can contain any characters, – Including any valid Unicode and international characters. • XML content can be as long as necessary
  • 21.
  • 22. XML document with an internal DTD • A DTD defines the structure & the legal elements and attributes of an XML document. • An application can use a DTD to verify that XML data is valid. • If the DTD is declared inside the XML file, – It must be wrapped inside the <!DOCTYPE> definition. • Document Type Declaration (DOCTYPE) gives a name to the XML content
  • 23. Document Type Declaration (DOCTYPE) • A DTD defines the structure & the legal elements and attributes of an XML document. • An application can use a DTD to verify that XML data is valid. • If the DTD is declared inside the XML file, – It must be wrapped inside the <!DOCTYPE> definition. • Document Type Declaration (DOCTYPE) gives a name to the XML content