SlideShare a Scribd company logo
1 of 17
INTRODUCTION TO XML
Tatyana Kosova
May 30, 2013 www.ExigenServices.com
2 www.ExigenServices.com
• WHAT IS XML
• XML SYNTAX
• XML TAGS
• XML ELEMENTS
• XML ATTRIBUTES
• XML SCHEME
• XML TOOLS
3 www.ExigenServices.com
XML
• Is a standart for EXtensible Markup Language
• Is a markup language much like HTML
• XML was designed to describe data
• XML tags are not predefined. You must define your own tags
• XML uses a Document Type Definition (DTD) or an
XML Schema to describe the data
4 www.ExigenServices.com
IMPORTANT TO KNOW!
XML doesn’t
DO anything!
Just structure,
store and send
information.
5 www.ExigenServices.com
XML SYNTAX
• XML declaration (standart and encoding)
• Can be comment (is inserted in tags <!-- comment -->)
• Element
• Child elements
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--DOCTYPE note SYSTEM "InternalNote.dtd“-->
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML Example:
6 www.ExigenServices.com
XML TAGS
• All XML documents must have closing a tag
<element> this is an element </element>
<element1>this is another element </element1>
• XML tags are case sensitive
<!– correct -->
<element> this is an element </element>
<!– wrong -->
<element1>this is another element </Element1>
• All XML documents must be properly nested
<!– correct -->
<b><i> this text is bold and italic </i></b>
<!– wrong -->
<b><i> this text is bold and italic </b></i>
7 www.ExigenServices.com
XML ELEMENTS
• XML elements are related as parents and children
<root>
<child>
<subchild>….</subchild>
</child>
</root>
8 www.ExigenServices.com
XML ELEMENTS NAMING
• XML elements have the different content type
<book>
<title>BOOK TITLE</title>
<prod id="33-657"
media="paper"></prod>
<chapter>CHAPTER ONE
<para>paragraph 1</para>
<para>paragraph 2</para>
</chapter>
<chapter>CHAPTER TWO
<para>paragraph 1</para>
</chapter>
</book>
9 www.ExigenServices.com
XML ATTRIBUTES
• Attribute values must always be enclosed in quotes
<person sex="female">
• If the attribute value itself contains double quotes it is necessary
to use single quotes
or <person sex=‘female’>
<gangster name='George "Shotgun" Ziegler'>
• If the attribute value itself contains single quotes it is necessary
to use double quotes
<gangster name=“George ‘Shotgun’ Ziegler”>
10 www.ExigenServices.com
XML ATTRIBUTES
• The following example defines an element called "age" with a restriction.
The value of age cannot be lower than 0 or greater than 120:
<xs:element name="age">
< xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="120"/>
</xs:restriction>
< /xs:simpleType>
< /xs:element>
11 www.ExigenServices.com
DTD SCHEME
• Attribute’s type and property
<!ATTLIST message
number CDATA #REQUIRED
date CDATA #REQUIRED
from CDATA #FIXED
status CDATA #IMPLIED>
• Elements and attributes should be described in DTD in order they used in
XML
• DTD can be defined in XML in second line
<?xml version="1.0" ?>
<!DOCTYPE mailbox SYSTEM "mailbox.dtd">
12 www.ExigenServices.com
DTD EXAMPLE
<!ELEMENT mailbox (message*)>
<!ELEMENT message (head, body)>
<!ATTLIST message uid CDATA #REQUIRED>
<!ELEMENT head ( from,to+, subject?, CC*,
notify?) >
<!ELEMENT from (#PCDATA)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT subject (#PCDATA)>
<!ELEMENT CC (#PCDATA)>
<!ELEMENT notify EMPTY>
<!ELEMENT body (#PCDATA)>
<?xml version="1.0" ?>
<!DOCTYPE mailbox SYSTEM
"mailbox.dtd">
<mailbox>
<message uid="1">
<head>
<from>user1@myhp.edu</from>
<to>user2@myhp.edu</to>
<subject>Re:</subject>
</head>
<body> What's up! </body>
</message>
<message uid="2">
…
</message>
</mailbox>
DTD XML
13 www.ExigenServices.com
XSD EXAMPLE
<?xml version="1.0"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLScheme
">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading"
type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0"?>
<xs:schema
xmlns:xs="http://www.w3.org/20
01/XMLScheme">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Hello!</body>
</note>
XMLXML SCHEME
14 www.ExigenServices.com
XML tools
• XML on-line validators
http://www.w3schools.com/dom/dom_validate.asp
• XML validators
XML ValidatorBuddy
• XML tools:
• Stylus Studio
• XML Notepad
• XML Copy Editor
• Exchanger XML Lite
• XMLPad
• XML Spy
15 www.ExigenServices.com
RESOLUTION
• XML was designed to carry data.
• XML has it’s own syntax
• XML should has a scheme
• XML document contains elements and attributes
• XML document has tags
• XML document is easy to create and validate
16 www.ExigenServices.com
<?xml version="1.0" encoding="WINDOWS-1251"?>
<?xml-stylesheet type='text/xsl' href='ex01-1.xsl'?>
<tutorial>
<title>“Introduction to XML"</title>
<author>Bob Hitch</author>
</toturial>
WRONG OR CORRECT
17 www.ExigenServices.com
QUESTIONS?

More Related Content

What's hot

Interacting with the DOM (JavaScript)
Interacting with the DOM (JavaScript)Interacting with the DOM (JavaScript)
Interacting with the DOM (JavaScript)Florence Davis
 
Javascript inside Browser (DOM)
Javascript inside Browser (DOM)Javascript inside Browser (DOM)
Javascript inside Browser (DOM)Vlad Mysla
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyAyes Chinmay
 
FFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLFFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLToni Kolev
 
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...Ayes Chinmay
 
Efficient use of jQuery selector
Efficient use of jQuery selectorEfficient use of jQuery selector
Efficient use of jQuery selectorchandrashekher786
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothBhavsingh Maloth
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQueryAlan Hecht
 
CSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersCSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersDarren Gideon
 
Internet and Web Technology (CLASS-6) [BOM]
Internet and Web Technology (CLASS-6) [BOM] Internet and Web Technology (CLASS-6) [BOM]
Internet and Web Technology (CLASS-6) [BOM] Ayes Chinmay
 
CSS- Smacss Design Rule
CSS- Smacss Design RuleCSS- Smacss Design Rule
CSS- Smacss Design Rule皮馬 頑
 
LF_APIStrat17_Embracing JSON Schema
LF_APIStrat17_Embracing JSON SchemaLF_APIStrat17_Embracing JSON Schema
LF_APIStrat17_Embracing JSON SchemaLF_APIStrat
 
Create an Design JSON Schema
Create an Design JSON SchemaCreate an Design JSON Schema
Create an Design JSON SchemaOctavian Nadolu
 
Web Development Basics: HOW TO in HTML
Web Development Basics: HOW TO in HTMLWeb Development Basics: HOW TO in HTML
Web Development Basics: HOW TO in HTMLDer Lo
 
Objects, Objects Everywhere
Objects, Objects EverywhereObjects, Objects Everywhere
Objects, Objects EverywhereMike Pack
 

What's hot (20)

Interacting with the DOM (JavaScript)
Interacting with the DOM (JavaScript)Interacting with the DOM (JavaScript)
Interacting with the DOM (JavaScript)
 
Javascript inside Browser (DOM)
Javascript inside Browser (DOM)Javascript inside Browser (DOM)
Javascript inside Browser (DOM)
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
 
Selenium Locators
Selenium LocatorsSelenium Locators
Selenium Locators
 
FFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLFFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTML
 
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
 
Efficient use of jQuery selector
Efficient use of jQuery selectorEfficient use of jQuery selector
Efficient use of jQuery selector
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
CSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersCSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI Developers
 
Internet and Web Technology (CLASS-6) [BOM]
Internet and Web Technology (CLASS-6) [BOM] Internet and Web Technology (CLASS-6) [BOM]
Internet and Web Technology (CLASS-6) [BOM]
 
CSS- Smacss Design Rule
CSS- Smacss Design RuleCSS- Smacss Design Rule
CSS- Smacss Design Rule
 
LF_APIStrat17_Embracing JSON Schema
LF_APIStrat17_Embracing JSON SchemaLF_APIStrat17_Embracing JSON Schema
LF_APIStrat17_Embracing JSON Schema
 
Create an Design JSON Schema
Create an Design JSON SchemaCreate an Design JSON Schema
Create an Design JSON Schema
 
Java Script Basics
Java Script BasicsJava Script Basics
Java Script Basics
 
Introductory css and j query
Introductory css and j queryIntroductory css and j query
Introductory css and j query
 
JSON Schema Design
JSON Schema DesignJSON Schema Design
JSON Schema Design
 
Web Development Basics: HOW TO in HTML
Web Development Basics: HOW TO in HTMLWeb Development Basics: HOW TO in HTML
Web Development Basics: HOW TO in HTML
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
 
Objects, Objects Everywhere
Objects, Objects EverywhereObjects, Objects Everywhere
Objects, Objects Everywhere
 

Viewers also liked (16)

Quick Start to AngularJS
Quick Start to AngularJSQuick Start to AngularJS
Quick Start to AngularJS
 
Организация тестирования производительности по Sweat
Организация тестирования производительности по SweatОрганизация тестирования производительности по Sweat
Организация тестирования производительности по Sweat
 
Enterprise service bus part 2
Enterprise service bus part 2Enterprise service bus part 2
Enterprise service bus part 2
 
Time Management
Time ManagementTime Management
Time Management
 
Unit Tests? It is Very Simple and Easy!
Unit Tests? It is Very Simple and Easy!Unit Tests? It is Very Simple and Easy!
Unit Tests? It is Very Simple and Easy!
 
Apache cassandra - future without boundaries (part2)
Apache cassandra - future without boundaries (part2)Apache cassandra - future without boundaries (part2)
Apache cassandra - future without boundaries (part2)
 
English for e mails
English for e mailsEnglish for e mails
English for e mails
 
Anti patterns part 2
Anti patterns part 2Anti patterns part 2
Anti patterns part 2
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
Windows Azure Service Bus
Windows Azure Service BusWindows Azure Service Bus
Windows Azure Service Bus
 
Agile Projects Estimation and Planning
Agile Projects Estimation and PlanningAgile Projects Estimation and Planning
Agile Projects Estimation and Planning
 
How to develop your creativity
How to develop your creativityHow to develop your creativity
How to develop your creativity
 
Enterprise Service Bus
Enterprise Service BusEnterprise Service Bus
Enterprise Service Bus
 
Telephoning in english
Telephoning in englishTelephoning in english
Telephoning in english
 
Gwt Deep Dive
Gwt Deep DiveGwt Deep Dive
Gwt Deep Dive
 
Distributed Agile, What types of Agile to use
Distributed Agile, What types of Agile to useDistributed Agile, What types of Agile to use
Distributed Agile, What types of Agile to use
 

Similar to Introduction to xml (20)

XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
XML Schema
XML SchemaXML Schema
XML Schema
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
 
XML DTD and Schema
XML DTD and SchemaXML DTD and Schema
XML DTD and Schema
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XML SCHEMAS
XML SCHEMASXML SCHEMAS
XML SCHEMAS
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
 
Xsd
XsdXsd
Xsd
 
Xsd
XsdXsd
Xsd
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
 
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
 
Service Oriented Architecture-Unit-1-XML Schema
Service Oriented Architecture-Unit-1-XML SchemaService Oriented Architecture-Unit-1-XML Schema
Service Oriented Architecture-Unit-1-XML Schema
 
Xml part4
Xml part4Xml part4
Xml part4
 
Xml schema
Xml schemaXml schema
Xml schema
 
XML Schema.pdf
XML Schema.pdfXML Schema.pdf
XML Schema.pdf
 
Xml sasidhar
Xml  sasidharXml  sasidhar
Xml sasidhar
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
Xml intro1
Xml intro1Xml intro1
Xml intro1
 

More from Return on Intelligence

Introduction to Backbone.js & Marionette.js
Introduction to Backbone.js & Marionette.jsIntroduction to Backbone.js & Marionette.js
Introduction to Backbone.js & Marionette.jsReturn on Intelligence
 
Types of testing and their classification
Types of testing and their classificationTypes of testing and their classification
Types of testing and their classificationReturn on Intelligence
 
Apache cassandra - future without boundaries (part3)
Apache cassandra - future without boundaries (part3)Apache cassandra - future without boundaries (part3)
Apache cassandra - future without boundaries (part3)Return on Intelligence
 
Apache cassandra - future without boundaries (part1)
Apache cassandra - future without boundaries (part1)Apache cassandra - future without boundaries (part1)
Apache cassandra - future without boundaries (part1)Return on Intelligence
 

More from Return on Intelligence (20)

Clean Code Approach
Clean Code ApproachClean Code Approach
Clean Code Approach
 
Code Coverage
Code CoverageCode Coverage
Code Coverage
 
Effective Communication in english
Effective Communication in englishEffective Communication in english
Effective Communication in english
 
Anti-patterns
Anti-patternsAnti-patterns
Anti-patterns
 
Conflicts Resolving
Conflicts ResolvingConflicts Resolving
Conflicts Resolving
 
Database versioning with liquibase
Database versioning with liquibaseDatabase versioning with liquibase
Database versioning with liquibase
 
Effective Feedback
Effective FeedbackEffective Feedback
Effective Feedback
 
English for Negotiations 2016
English for Negotiations 2016English for Negotiations 2016
English for Negotiations 2016
 
Lean Software Development
Lean Software DevelopmentLean Software Development
Lean Software Development
 
Introduction to Backbone.js & Marionette.js
Introduction to Backbone.js & Marionette.jsIntroduction to Backbone.js & Marionette.js
Introduction to Backbone.js & Marionette.js
 
Types of testing and their classification
Types of testing and their classificationTypes of testing and their classification
Types of testing and their classification
 
Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
Apache cassandra - future without boundaries (part3)
Apache cassandra - future without boundaries (part3)Apache cassandra - future without boundaries (part3)
Apache cassandra - future without boundaries (part3)
 
Apache cassandra - future without boundaries (part1)
Apache cassandra - future without boundaries (part1)Apache cassandra - future without boundaries (part1)
Apache cassandra - future without boundaries (part1)
 
Career development in exigen services
Career development in exigen servicesCareer development in exigen services
Career development in exigen services
 
Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
 
Enterprise service bus part 2
Enterprise service bus part 2Enterprise service bus part 2
Enterprise service bus part 2
 
Enterprise service bus part 1
Enterprise service bus part 1Enterprise service bus part 1
Enterprise service bus part 1
 
Apache maven 2. advanced topics
Apache maven 2. advanced topicsApache maven 2. advanced topics
Apache maven 2. advanced topics
 
Jira as a test management tool
Jira as a test management toolJira as a test management tool
Jira as a test management tool
 

Recently uploaded

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

Introduction to xml

  • 1. INTRODUCTION TO XML Tatyana Kosova May 30, 2013 www.ExigenServices.com
  • 2. 2 www.ExigenServices.com • WHAT IS XML • XML SYNTAX • XML TAGS • XML ELEMENTS • XML ATTRIBUTES • XML SCHEME • XML TOOLS
  • 3. 3 www.ExigenServices.com XML • Is a standart for EXtensible Markup Language • Is a markup language much like HTML • XML was designed to describe data • XML tags are not predefined. You must define your own tags • XML uses a Document Type Definition (DTD) or an XML Schema to describe the data
  • 4. 4 www.ExigenServices.com IMPORTANT TO KNOW! XML doesn’t DO anything! Just structure, store and send information.
  • 5. 5 www.ExigenServices.com XML SYNTAX • XML declaration (standart and encoding) • Can be comment (is inserted in tags <!-- comment -->) • Element • Child elements <?xml version="1.0" encoding="ISO-8859-1"?> <!--DOCTYPE note SYSTEM "InternalNote.dtd“--> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> XML Example:
  • 6. 6 www.ExigenServices.com XML TAGS • All XML documents must have closing a tag <element> this is an element </element> <element1>this is another element </element1> • XML tags are case sensitive <!– correct --> <element> this is an element </element> <!– wrong --> <element1>this is another element </Element1> • All XML documents must be properly nested <!– correct --> <b><i> this text is bold and italic </i></b> <!– wrong --> <b><i> this text is bold and italic </b></i>
  • 7. 7 www.ExigenServices.com XML ELEMENTS • XML elements are related as parents and children <root> <child> <subchild>….</subchild> </child> </root>
  • 8. 8 www.ExigenServices.com XML ELEMENTS NAMING • XML elements have the different content type <book> <title>BOOK TITLE</title> <prod id="33-657" media="paper"></prod> <chapter>CHAPTER ONE <para>paragraph 1</para> <para>paragraph 2</para> </chapter> <chapter>CHAPTER TWO <para>paragraph 1</para> </chapter> </book>
  • 9. 9 www.ExigenServices.com XML ATTRIBUTES • Attribute values must always be enclosed in quotes <person sex="female"> • If the attribute value itself contains double quotes it is necessary to use single quotes or <person sex=‘female’> <gangster name='George "Shotgun" Ziegler'> • If the attribute value itself contains single quotes it is necessary to use double quotes <gangster name=“George ‘Shotgun’ Ziegler”>
  • 10. 10 www.ExigenServices.com XML ATTRIBUTES • The following example defines an element called "age" with a restriction. The value of age cannot be lower than 0 or greater than 120: <xs:element name="age"> < xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="120"/> </xs:restriction> < /xs:simpleType> < /xs:element>
  • 11. 11 www.ExigenServices.com DTD SCHEME • Attribute’s type and property <!ATTLIST message number CDATA #REQUIRED date CDATA #REQUIRED from CDATA #FIXED status CDATA #IMPLIED> • Elements and attributes should be described in DTD in order they used in XML • DTD can be defined in XML in second line <?xml version="1.0" ?> <!DOCTYPE mailbox SYSTEM "mailbox.dtd">
  • 12. 12 www.ExigenServices.com DTD EXAMPLE <!ELEMENT mailbox (message*)> <!ELEMENT message (head, body)> <!ATTLIST message uid CDATA #REQUIRED> <!ELEMENT head ( from,to+, subject?, CC*, notify?) > <!ELEMENT from (#PCDATA)> <!ELEMENT to (#PCDATA)> <!ELEMENT subject (#PCDATA)> <!ELEMENT CC (#PCDATA)> <!ELEMENT notify EMPTY> <!ELEMENT body (#PCDATA)> <?xml version="1.0" ?> <!DOCTYPE mailbox SYSTEM "mailbox.dtd"> <mailbox> <message uid="1"> <head> <from>user1@myhp.edu</from> <to>user2@myhp.edu</to> <subject>Re:</subject> </head> <body> What's up! </body> </message> <message uid="2"> … </message> </mailbox> DTD XML
  • 13. 13 www.ExigenServices.com XSD EXAMPLE <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLScheme "> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/20 01/XMLScheme"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Hello!</body> </note> XMLXML SCHEME
  • 14. 14 www.ExigenServices.com XML tools • XML on-line validators http://www.w3schools.com/dom/dom_validate.asp • XML validators XML ValidatorBuddy • XML tools: • Stylus Studio • XML Notepad • XML Copy Editor • Exchanger XML Lite • XMLPad • XML Spy
  • 15. 15 www.ExigenServices.com RESOLUTION • XML was designed to carry data. • XML has it’s own syntax • XML should has a scheme • XML document contains elements and attributes • XML document has tags • XML document is easy to create and validate
  • 16. 16 www.ExigenServices.com <?xml version="1.0" encoding="WINDOWS-1251"?> <?xml-stylesheet type='text/xsl' href='ex01-1.xsl'?> <tutorial> <title>“Introduction to XML"</title> <author>Bob Hitch</author> </toturial> WRONG OR CORRECT

Editor's Notes

  1. &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-16&amp;quot;?&amp;gt; will give an error message
  2. Elements can be simple and complex. Simple element is an XML element that can contain only text. It cannot contain any other elements or attributes. However, the &amp;quot;only text&amp;quot; restriction is quite misleading. The text can be of many different types. It can be one of the types included in the XML Schema definition (boolean, string, date, etc.), or it can be a custom type that you can define yourself. You can also add restrictions (facets) to a data type in order to limit its content, or you can require the data to match a specific pattern. The syntax for defining a simple element is: &amp;lt; xs:element name=&amp;quot;xxx&amp;quot; type=&amp;quot;yyy&amp;quot;/&amp;gt; where xxx is the name of the element and yyy is the data type of the element. XML Schema has a lot of built-in data types. The most common types are: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time Example Here are some XML elements: &amp;lt; lastname&amp;gt;Refsnes&amp;lt;/lastname&amp;gt;&amp;lt; age&amp;gt;36&amp;lt;/age&amp;gt;&amp;lt; dateborn&amp;gt;1970-03-27&amp;lt;/dateborn&amp;gt; And here are the corresponding simple element definitions: &amp;lt; xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt; xs:element name=&amp;quot;age&amp;quot; type=&amp;quot;xs:integer&amp;quot;/&amp;gt;&amp;lt; xs:element name=&amp;quot;dateborn&amp;quot; type=&amp;quot;xs:date&amp;quot;/&amp;gt; Simple elements may have a default value OR a fixed value specified. A default value is automatically assigned to the element when no other value is specified. In the following example the default value is &amp;quot;red&amp;quot;: &amp;lt; xs:element name=&amp;quot;color&amp;quot; type=&amp;quot;xs:string&amp;quot; default=&amp;quot;red&amp;quot;/&amp;gt; A fixed value is also automatically assigned to the element, and you cannot specify another value. In the following example the fixed value is &amp;quot;red&amp;quot;: &amp;lt; xs:element name=&amp;quot;color&amp;quot; type=&amp;quot;xs:string&amp;quot; fixed=&amp;quot;red&amp;quot;/&amp;gt; A complex element is an XML element that contains other elements and/or attributes. There are four kinds of complex elements: empty elements elements that contain only other elements elements that contain only text elements that contain both other elements and text Examples of Complex Elements A complex XML element, &amp;quot;product&amp;quot;, which is empty: &amp;lt; product pid=&amp;quot;1345&amp;quot;/&amp;gt; A complex XML element, &amp;quot;employee&amp;quot;, which contains only other elements: &amp;lt; employee&amp;gt;&amp;lt; firstname&amp;gt;John&amp;lt;/firstname&amp;gt;&amp;lt; lastname&amp;gt;Smith&amp;lt;/lastname&amp;gt;&amp;lt; /employee&amp;gt; A complex XML element, &amp;quot;food&amp;quot;, which contains only text: &amp;lt; food type=&amp;quot;dessert&amp;quot;&amp;gt;Ice cream&amp;lt;/food&amp;gt; A complex XML element, &amp;quot;description&amp;quot;, which contains both elements and text: &amp;lt; description&amp;gt;It happened on &amp;lt;date lang=&amp;quot;norwegian&amp;quot;&amp;gt;03.03.99&amp;lt;/date&amp;gt; ....&amp;lt; /description&amp;gt; How to Define a Complex Element Look at this complex XML element, &amp;quot;employee&amp;quot;, which contains only other elements: &amp;lt; employee&amp;gt;&amp;lt; firstname&amp;gt;John&amp;lt;/firstname&amp;gt;&amp;lt; lastname&amp;gt;Smith&amp;lt;/lastname&amp;gt;&amp;lt; /employee&amp;gt; We can define a complex element in an XML Schema two different ways: 1. The &amp;quot;employee&amp;quot; element can be declared directly by naming the element, like this: &amp;lt; xs:element name=&amp;quot;employee&amp;quot;&amp;gt;&amp;lt;xs:complexType&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;firstname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt;/xs:complexType&amp;gt;&amp;lt; /xs:element&amp;gt; If you use the method described above, only the &amp;quot;employee&amp;quot; element can use the specified complex type. Note that the child elements, &amp;quot;firstname&amp;quot; and &amp;quot;lastname&amp;quot;, are surrounded by the &amp;lt;sequence&amp;gt; indicator. This means that the child elements must appear in the same order as they are declared. You will learn more about indicators in the XSD Indicators chapter. 2. The &amp;quot;employee&amp;quot; element can have a type attribute that refers to the name of the complex type to use: &amp;lt; xs:element name=&amp;quot;employee&amp;quot; type=&amp;quot;personinfo&amp;quot;/&amp;gt;&amp;lt; xs:complexType name=&amp;quot;personinfo&amp;quot;&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;firstname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt; /xs:complexType&amp;gt; If you use the method described above, several elements can refer to the same complex type, like this: &amp;lt; xs:element name=&amp;quot;employee&amp;quot; type=&amp;quot;personinfo&amp;quot;/&amp;gt;&amp;lt; xs:element name=&amp;quot;student&amp;quot; type=&amp;quot;personinfo&amp;quot;/&amp;gt;&amp;lt; xs:element name=&amp;quot;member&amp;quot; type=&amp;quot;personinfo&amp;quot;/&amp;gt;&amp;lt; xs:complexType name=&amp;quot;personinfo&amp;quot;&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;firstname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt; /xs:complexType&amp;gt; You can also base a complex element on an existing complex element and add some elements, like this: &amp;lt; xs:element name=&amp;quot;employee&amp;quot; type=&amp;quot;fullpersoninfo&amp;quot;/&amp;gt;&amp;lt; xs:complexType name=&amp;quot;personinfo&amp;quot;&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;firstname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt; /xs:complexType&amp;gt;&amp;lt; xs:complexType name=&amp;quot;fullpersoninfo&amp;quot;&amp;gt;&amp;lt;xs:complexContent&amp;gt;&amp;lt;xs:extension base=&amp;quot;personinfo&amp;quot;&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;address&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;city&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;country&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt;/xs:extension&amp;gt;&amp;lt;/xs:complexContent&amp;gt;&amp;lt; /xs:complexType&amp;gt; Complex Types Containing Elements Only An XML element, &amp;quot;person&amp;quot;, that contains only other elements: &amp;lt; person&amp;gt;&amp;lt; firstname&amp;gt;John&amp;lt;/firstname&amp;gt;&amp;lt; lastname&amp;gt;Smith&amp;lt;/lastname&amp;gt;&amp;lt; /person&amp;gt; You can define the &amp;quot;person&amp;quot; element in a schema, like this: &amp;lt; xs:element name=&amp;quot;person&amp;quot;&amp;gt;&amp;lt;xs:complexType&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;firstname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt;/xs:complexType&amp;gt;&amp;lt; /xs:element&amp;gt; Notice the &amp;lt;xs:sequence&amp;gt; tag. It means that the elements defined (&amp;quot;firstname&amp;quot; and &amp;quot;lastname&amp;quot;) must appear in that order inside a &amp;quot;person&amp;quot; element. Or you can give the complexType element a name, and let the &amp;quot;person&amp;quot; element have a type attribute that refers to the name of the complexType (if you use this method, several elements can refer to the same complex type): &amp;lt; xs:element name=&amp;quot;person&amp;quot; type=&amp;quot;persontype&amp;quot;/&amp;gt;&amp;lt; xs:complexType name=&amp;quot;persontype&amp;quot;&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;firstname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt; /xs:complexType&amp;gt; Complex Types with Mixed Content An XML element, &amp;quot;letter&amp;quot;, that contains both text and other elements: &amp;lt; letter&amp;gt;Dear Mr.&amp;lt;name&amp;gt;John Smith&amp;lt;/name&amp;gt;.Your order &amp;lt;orderid&amp;gt;1032&amp;lt;/orderid&amp;gt;will be shipped on &amp;lt;shipdate&amp;gt;2001-07-13&amp;lt;/shipdate&amp;gt;.&amp;lt; /letter&amp;gt; The following schema declares the &amp;quot;letter&amp;quot; element: &amp;lt; xs:element name=&amp;quot;letter&amp;quot;&amp;gt;&amp;lt;xs:complexType mixed=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;name&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;orderid&amp;quot; type=&amp;quot;xs:positiveInteger&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;shipdate&amp;quot; type=&amp;quot;xs:date&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt;/xs:complexType&amp;gt;&amp;lt; /xs:element&amp;gt; Note: To enable character data to appear between the child-elements of &amp;quot;letter&amp;quot;, the mixed attribute must be set to &amp;quot;true&amp;quot;. The &amp;lt;xs:sequence&amp;gt; tag means that the elements defined (name, orderid and shipdate) must appear in that order inside a &amp;quot;letter&amp;quot; element. We could also give the complexType element a name, and let the &amp;quot;letter&amp;quot; element have a type attribute that refers to the name of the complexType (if you use this method, several elements can refer to the same complex type): &amp;lt; xs:element name=&amp;quot;letter&amp;quot; type=&amp;quot;lettertype&amp;quot;/&amp;gt;&amp;lt; xs:complexType name=&amp;quot;lettertype&amp;quot; mixed=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;name&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;orderid&amp;quot; type=&amp;quot;xs:positiveInteger&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;shipdate&amp;quot; type=&amp;quot;xs:date&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt; /xs:complexType&amp;gt;
  3. XML elements can have different content type: element content, mixed content, Simple content or empty content or element can have attribute. Simple elements cannot have attributes. If an element has attributes, it is considered to be of a complex type. But the attribute itself is always declared as a simple type. Element “title” has content type, element “prod” doesn’t have any type but has an attribute. Element “chapter” has content and mixed type. Element “para” has content type. Element “book” and “chapter”ia a parent element and has child elements. The attribute named id has the value &amp;quot;33-657&amp;quot;. The attribute named media has the value &amp;quot;paper&amp;quot;.
  4. Example Here is an XML element with an attribute: &amp;lt; lastname lang=&amp;quot;EN&amp;quot;&amp;gt;Smith&amp;lt;/lastname&amp;gt; And here is the corresponding attribute definition: &amp;lt; xs:attribute name=&amp;quot;lang&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt; Default and Fixed Values for Attributes Attributes may have a default value OR a fixed value specified. A default value is automatically assigned to the attribute when no other value is specified. In the following example the default value is &amp;quot;EN&amp;quot;: &amp;lt; xs:attribute name=&amp;quot;lang&amp;quot; type=&amp;quot;xs:string&amp;quot; default=&amp;quot;EN&amp;quot;/&amp;gt; A fixed value is also automatically assigned to the attribute, and you cannot specify another value. In the following example the fixed value is &amp;quot;EN&amp;quot;: &amp;lt; xs:attribute name=&amp;quot;lang&amp;quot; type=&amp;quot;xs:string&amp;quot; fixed=&amp;quot;EN&amp;quot;/&amp;gt; Optional and Required Attributes Attributes are optional by default. To specify that the attribute is required, use the &amp;quot;use&amp;quot; attribute: &amp;lt; xs:attribute name=&amp;quot;lang&amp;quot; type=&amp;quot;xs:string&amp;quot; use=&amp;quot;required&amp;quot;/&amp;gt; Restrictions on Content When an XML element or attribute has a data type defined, it puts restrictions on the element&amp;apos;s or attribute&amp;apos;s content. If an XML element is of type &amp;quot;xs:date&amp;quot; and contains a string like &amp;quot;Hello World&amp;quot;, the element will not validate. With XML Schemas, you can also add your own restrictions to your XML elements and attributes. These restrictions are called facets. You can read more about facets in the next chapter.
  5. To limit the content of an XML element to a set of acceptable values, we would use the enumeration constraint. The example below defines an element called &amp;quot;car&amp;quot; with a restriction. The only acceptable values are: Audi, Golf, BMW: &amp;lt; xs:element name=&amp;quot;car&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:enumeration value=&amp;quot;Audi&amp;quot;/&amp;gt;&amp;lt;xs:enumeration value=&amp;quot;Golf&amp;quot;/&amp;gt;&amp;lt;xs:enumeration value=&amp;quot;BMW&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt; /xs:element&amp;gt; The example above could also have been written like this: &amp;lt; xs:element name=&amp;quot;car&amp;quot; type=&amp;quot;carType&amp;quot;/&amp;gt;&amp;lt; xs:simpleType name=&amp;quot;carType&amp;quot;&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:enumeration value=&amp;quot;Audi&amp;quot;/&amp;gt;&amp;lt;xs:enumeration value=&amp;quot;Golf&amp;quot;/&amp;gt;&amp;lt;xs:enumeration value=&amp;quot;BMW&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt; Note: In this case the type &amp;quot;carType&amp;quot; can be used by other elements because it is not a part of the &amp;quot;car&amp;quot; element. To limit the content of an XML element to define a series of numbers or letters that can be used, we would use the pattern constraint. The example below defines an element called &amp;quot;letter&amp;quot; with a restriction. The only acceptable value is ONE of the LOWERCASE letters from a to z: &amp;lt; xs:element name=&amp;quot;letter&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;[a-z]&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt; The next example defines an element called &amp;quot;initials&amp;quot; with a restriction. The only acceptable value is THREE of the UPPERCASE letters from a to z: &amp;lt; xs:element name=&amp;quot;initials&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;[A-Z][A-Z][A-Z]&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt; The next example also defines an element called &amp;quot;initials&amp;quot; with a restriction. The only acceptable value is THREE of the LOWERCASE OR UPPERCASE letters from a to z: &amp;lt; xs:element name=&amp;quot;initials&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;[a-zA-Z][a-zA-Z][a-zA-Z]&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt; The next example defines an element called &amp;quot;choice&amp;quot; with a restriction. The only acceptable value is ONE of the following letters: x, y, OR z: &amp;lt; xs:element name=&amp;quot;choice&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;[xyz]&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt; The next example defines an element called &amp;quot;prodid&amp;quot; with a restriction. The only acceptable value is FIVE digits in a sequence, and each digit must be in a range from 0 to 9: &amp;lt; xs:element name=&amp;quot;prodid&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:integer&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;[0-9][0-9][0-9][0-9][0-9]&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt; Other Restrictions on a Series of Values The example below defines an element called &amp;quot;letter&amp;quot; with a restriction. The acceptable value is zero or more occurrences of lowercase letters from a to z: &amp;lt; xs:element name=&amp;quot;letter&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;([a-z])*&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt; The next example also defines an element called &amp;quot;letter&amp;quot; with a restriction. The acceptable value is one or more pairs of letters, each pair consisting of a lower case letter followed by an upper case letter. For example, &amp;quot;sToP&amp;quot; will be validated by this pattern, but not &amp;quot;Stop&amp;quot; or &amp;quot;STOP&amp;quot; or &amp;quot;stop&amp;quot;: &amp;lt; xs:element name=&amp;quot;letter&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;([a-z][A-Z])+&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt; The next example defines an element called &amp;quot;gender&amp;quot; with a restriction. The only acceptable value is male OR female: &amp;lt; xs:element name=&amp;quot;gender&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;male|female&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt; The next example defines an element called &amp;quot;password&amp;quot; with a restriction. There must be exactly eight characters in a row and those characters must be lowercase or uppercase letters from a to z, or a number from 0 to 9: &amp;lt; xs:element name=&amp;quot;password&amp;quot;&amp;gt;&amp;lt; xs:simpleType&amp;gt;&amp;lt;xs:restriction base=&amp;quot;xs:string&amp;quot;&amp;gt;&amp;lt;xs:pattern value=&amp;quot;[a-zA-Z0-9]{8}&amp;quot;/&amp;gt;&amp;lt;/xs:restriction&amp;gt;&amp;lt; /xs:simpleType&amp;gt;&amp;lt;/xs:element&amp;gt;
  6. The DTD describes a scheme for a particular document markup language using a set of declarations (objects, options, elements and attributes) that describe its class (or type) in terms of syntactic constraints of this document. DTD may also declare constructs that are always needed to determine the structure of the document, but, but may influence the interpretation of certain documents. The attribute named id has the value &amp;quot;33-657&amp;quot;. The attribute named media has the value &amp;quot;paper&amp;quot;. REQUIRED – attribute should be identified. FIXED - attribute should be fixed. IMPLIED - attribute can be unengaging. There are some default properties: 1.IMPLIED - attribute is optional; 2.REQUIRED - the attribute value must be indicated; 3.FIXED - the value of this attribute is specified as a constant in the DTD and the document can not be changed; 4.nekotoroe specific value, which is used by default.
  7. The attribute named id has the value &amp;quot;33-657&amp;quot;. The attribute named media has the value &amp;quot;paper&amp;quot;. Declare elements form a list of authorized names of elements in the document and determine the information on the tags (if they are mandatory) and the content model for each element. Different keys words and symbols define the contents of: EMPTY - empty the contents of ANY - any content - Specifies the order | - Separation of alternatives () - Grouping * - Any number of items (zero or more) + - At least one element (one or more) ? - Availability of an optional element (zero or one) If there is no, * +, or? - The item should be only one There are some types of attributes: CDATA (Character set of data) - the attribute value can be any character data ID - the attribute value must be a unique identifier for the element IDREF - the element value is a reference to an element by its ID IDREFS - Same as IDREF, but with the possibility of links is not one identifier, and for several NMTOKEN - an attribute value can be a sequence of characters, in some ways similar to the name (hence the name - name token). This is a string that contains any combination of those characters that are allowed to use names for XML. NMTOKENS - the attribute value is a list of values ENTITY - the value used to refer to an external entity. ENTITIES - allows you to specify a list of external entities, separated by spaces. NOTATION - the attribute value can be one of the previously defined notations NOTATIONS - allows you to specify a list of notations. Listings and NOTATION-listings ENUMERATION - sets a list of possible alternative values. There are some default properties: 1.IMPLIED - attribute is optional; 2.REQUIRED - the attribute value must be indicated; 3.FIXED - the value of this attribute is specified as a constant in the DTD and the document can not be changed; 4.nekotoroe specific value, which is used by default.
  8. What is an XML Schema? The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. An XML Schema: defines elements that can appear in a document defines attributes that can appear in a document defines which elements are child elements defines the order of child elements defines the number of child elements defines whether an element is empty or can include text defines data types for elements and attributes defines default and fixed values for elements and attributes XML Schemas are the Successors of DTDs We think that very soon XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons: XML Schemas are extensible to future additions XML Schemas are richer and more powerful than DTDs XML Schemas are written in XML XML Schemas support data types XML Schemas support namespaces XML Schema is a W3C Recommendation XML Schema became a W3C Recommendation 02. May 2001. You can read more about the XML Schema standard in our W3C tutorial. We believe that very soon XML-schema to be used in Web-based applications instead of the DTD-tables, and here&amp;apos;s why: XML-schemas easier to learn than DTD XML-schema can be expanded in the future if needed to add some XML-Schema is richer and more useful than DTD XML-schema written in XML XML-Schema data typing support XML-schema namespace support &amp;lt;xs:element name=&amp;quot;to&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt; - is a simple element &amp;lt;xs:element name=&amp;quot;note&amp;quot;&amp;gt; - is a complex element XML Schema has a lot of built-in data types. The most common types are: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time Order indicators are used to define the order of the elements. All Indicator The &amp;lt;all&amp;gt; indicator specifies that the child elements can appear in any order, and that each child element must occur only once: &amp;lt; xs:element name=&amp;quot;person&amp;quot;&amp;gt;&amp;lt;xs:complexType&amp;gt;&amp;lt;xs:all&amp;gt;&amp;lt;xs:element name=&amp;quot;firstname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:all&amp;gt;&amp;lt;/xs:complexType&amp;gt;&amp;lt; /xs:element&amp;gt; Note: When using the &amp;lt;all&amp;gt; indicator you can set the &amp;lt;minOccurs&amp;gt; indicator to 0 or 1 and the &amp;lt;maxOccurs&amp;gt; indicator can only be set to 1 (the &amp;lt;minOccurs&amp;gt; and &amp;lt;maxOccurs&amp;gt; are described later). Choice Indicator The &amp;lt;choice&amp;gt; indicator specifies that either one child element or another can occur: &amp;lt; xs:element name=&amp;quot;person&amp;quot;&amp;gt;&amp;lt;xs:complexType&amp;gt;&amp;lt;xs:choice&amp;gt;&amp;lt;xs:element name=&amp;quot;employee&amp;quot; type=&amp;quot;employee&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;member&amp;quot; type=&amp;quot;member&amp;quot;/&amp;gt;&amp;lt;/xs:choice&amp;gt;&amp;lt;/xs:complexType&amp;gt;&amp;lt; /xs:element&amp;gt; Sequence Indicator The &amp;lt;sequence&amp;gt; indicator specifies that the child elements must appear in a specific order: &amp;lt; xs:element name=&amp;quot;person&amp;quot;&amp;gt;&amp;lt;xs:complexType&amp;gt;&amp;lt;xs:sequence&amp;gt;&amp;lt;xs:element name=&amp;quot;firstname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;xs:element name=&amp;quot;lastname&amp;quot; type=&amp;quot;xs:string&amp;quot;/&amp;gt;&amp;lt;/xs:sequence&amp;gt;&amp;lt;/xs:complexType&amp;gt;&amp;lt; /xs:element&amp;gt; XML Schemas Support Data Types One of the greatest strength of XML Schemas is the support for data types. With support for data types: It is easier to describe allowable document content It is easier to validate the correctness of data It is easier to work with data from a database It is easier to define data facets (restrictions on data) It is easier to define data patterns (data formats) It is easier to convert data between different data types XML Schemas use XML Syntax Another great strength about XML Schemas is that they are written in XML. Some benefits of that XML Schemas are written in XML: You don&amp;apos;t have to learn a new language You can use your XML editor to edit your Schema files You can use your XML parser to parse your Schema files You can manipulate your Schema with the XML DOM You can transform your Schema with XSLT XML Schemas Secure Data Communication When sending data from a sender to a receiver, it is essential that both parts have the same &amp;quot;expectations&amp;quot; about the content. With XML Schemas, the sender can describe the data in a way that the receiver will understand. A date like: &amp;quot;03-11-2004&amp;quot; will, in some countries, be interpreted as 3.November and in other countries as 11.March. However, an XML element with a data type like this: &amp;lt;date type=&amp;quot;date&amp;quot;&amp;gt;2004-03-11&amp;lt;/date&amp;gt; ensures a mutual understanding of the content, because the XML data type &amp;quot;date&amp;quot; requires the format &amp;quot;YYYY-MM-DD&amp;quot;. XML Schemas are Extensible XML Schemas are extensible, because they are written in XML. With an extensible Schema definition you can: Reuse your Schema in other Schemas Create your own data types derived from the standard types Reference multiple schemas in the same document Well-Formed is not Enough A well-formed XML document is a document that conforms to the XML syntax rules, like: it must begin with the XML declaration it must have one unique root element start-tags must have matching end-tags elements are case sensitive all elements must be closed all elements must be properly nested all attribute values must be quoted entities must be used for special characters Even if documents are well-formed they can still contain errors, and those errors can have serious consequences. Think of the following situation: you order 5 gross of laser printers, instead of 5 laser printers. With XML Schemas, most of these errors can be caught by your validating software.
  9. XML is Text-based XML is a text-based markup language. One great thing about XML is that XML files can be created and edited using a simple text-editor like Notepad. However, when you start working with XML, you will soon find that it is better to edit XML documents using a professional XML editor. Why Not Notepad? Many web developers use Notepad to edit both HTML and XML documents because Notepad is included with the most common OS and it is simple to use. Personally I often use Notepad for quick editing of simple HTML, CSS, and XML files. But, if you use Notepad for XML editing, you will soon run into problems. Notepad does not know that you are writing XML, so it will not be able to assist you. Why an XML Editor? Today XML is an important technology, and development projects use XML-based technologies like: XML Schema to define XML structures and data types XSLT to transform XML data SOAP to exchange XML data between applications WSDL to describe web services RDF to describe web resources XPath and XQuery to access XML data SMIL to define graphics To be able to write error-free XML documents, you will need an intelligent XML editor! XML Editors Professional XML editors will help you to write error-free XML documents, validate your XML against a DTD or a schema, and force you to stick to a valid XML structure. An XML editor should be able to: Add closing tags to your opening tags automatically Force you to write valid XML Verify your XML against a DTD Verify your XML against a Schema Color code your XML syntax
  10. &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;WINDOWS-1251&amp;quot;?&amp;gt; &amp;lt;?xml-stylesheet type=&amp;apos;text/xsl&amp;apos; href=&amp;apos;ex01-1.xsl&amp;apos;?&amp;gt; &amp;lt;tutorial&amp;gt; &amp;lt;title&amp;gt;“Introduction to XML&amp;quot;&amp;lt;/title&amp;gt; &amp;lt;author&amp;gt;Bob Hitch&amp;lt;/author&amp;gt; &amp;lt;/tutorial&amp;gt;