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

XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTDvidede_group
 
Non Blocking Algorithms at Traffic Conditions
Non Blocking Algorithms at Traffic ConditionsNon Blocking Algorithms at Traffic Conditions
Non Blocking Algorithms at Traffic ConditionsReturn on Intelligence
 
Profsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by PavelchukProfsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by PavelchukReturn on Intelligence
 
Successful interview for a young IT specialist
Successful interview for a young IT specialistSuccessful interview for a young IT specialist
Successful interview for a young IT specialistReturn on Intelligence
 
Apache Maven presentation from BitByte conference
Apache Maven presentation from BitByte conferenceApache Maven presentation from BitByte conference
Apache Maven presentation from BitByte conferenceReturn on Intelligence
 
Service design principles and patterns
Service design principles and patternsService design principles and patterns
Service design principles and patternsReturn on Intelligence
 

Viewers also liked (20)

XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
 
Xml Schema
Xml SchemaXml Schema
Xml Schema
 
How to develop your creativity
How to develop your creativityHow to develop your creativity
How to develop your creativity
 
Quality Principles
Quality PrinciplesQuality Principles
Quality Principles
 
Non Blocking Algorithms at Traffic Conditions
Non Blocking Algorithms at Traffic ConditionsNon Blocking Algorithms at Traffic Conditions
Non Blocking Algorithms at Traffic Conditions
 
English for E-mails
English for E-mailsEnglish for E-mails
English for E-mails
 
Profsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by PavelchukProfsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by Pavelchuk
 
Successful interview for a young IT specialist
Successful interview for a young IT specialistSuccessful interview for a young IT specialist
Successful interview for a young IT specialist
 
Windows Azure: Quick start
Windows Azure: Quick startWindows Azure: Quick start
Windows Azure: Quick start
 
Apache Maven presentation from BitByte conference
Apache Maven presentation from BitByte conferenceApache Maven presentation from BitByte conference
Apache Maven presentation from BitByte conference
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Time Management
Time ManagementTime Management
Time Management
 
Apache Maven 2 Part 2
Apache Maven 2 Part 2Apache Maven 2 Part 2
Apache Maven 2 Part 2
 
Agile Project Grows
Agile Project GrowsAgile Project Grows
Agile Project Grows
 
Large Scale Software Project
Large Scale Software ProjectLarge Scale Software Project
Large Scale Software Project
 
Jira as a test management tool
Jira as a test management toolJira as a test management tool
Jira as a test management tool
 
Service design principles and patterns
Service design principles and patternsService design principles and patterns
Service design principles and patterns
 
Risk Management
Risk ManagementRisk Management
Risk Management
 
Principles of personal effectiveness
Principles of personal effectivenessPrinciples of personal effectiveness
Principles of personal effectiveness
 
Cross-cultural communication
Cross-cultural communicationCross-cultural communication
Cross-cultural communication
 

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

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
 
Differences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and AgileDifferences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and AgileReturn on Intelligence
 
Организация внутренней системы обучения
Организация внутренней системы обученияОрганизация внутренней системы обучения
Организация внутренней системы обученияReturn on Intelligence
 
Shared position in a project: testing and analysis
Shared position in a project: testing and analysisShared position in a project: testing and analysis
Shared position in a project: testing and analysisReturn on Intelligence
 
Оценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработкеОценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработкеReturn on Intelligence
 
Velocity как инструмент планирования и управления проектом
Velocity как инструмент планирования и управления проектомVelocity как инструмент планирования и управления проектом
Velocity как инструмент планирования и управления проектомReturn on Intelligence
 

More from Return on Intelligence (15)

Types of testing and their classification
Types of testing and their classificationTypes of testing and their classification
Types of testing and their classification
 
Differences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and AgileDifferences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and Agile
 
Windows azurequickstart
Windows azurequickstartWindows azurequickstart
Windows azurequickstart
 
Организация внутренней системы обучения
Организация внутренней системы обученияОрганизация внутренней системы обучения
Организация внутренней системы обучения
 
Shared position in a project: testing and analysis
Shared position in a project: testing and analysisShared position in a project: testing and analysis
Shared position in a project: testing and analysis
 
Introduction to Business Etiquette
Introduction to Business EtiquetteIntroduction to Business Etiquette
Introduction to Business Etiquette
 
Agile Testing Process
Agile Testing ProcessAgile Testing Process
Agile Testing Process
 
Оценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработкеОценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработке
 
Meetings arranging
Meetings arrangingMeetings arranging
Meetings arranging
 
The art of project estimation
The art of project estimationThe art of project estimation
The art of project estimation
 
Resolving conflicts
Resolving conflictsResolving conflicts
Resolving conflicts
 
Velocity как инструмент планирования и управления проектом
Velocity как инструмент планирования и управления проектомVelocity как инструмент планирования и управления проектом
Velocity как инструмент планирования и управления проектом
 
Testing your code
Testing your codeTesting your code
Testing your code
 
Reports Project
Reports ProjectReports Project
Reports Project
 
Business Analyst lecture
Business Analyst lectureBusiness Analyst lecture
Business Analyst lecture
 

Recently uploaded

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

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. &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&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 &quot;only text&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: &lt; xs:element name=&quot;xxx&quot; type=&quot;yyy&quot;/&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: &lt; lastname&gt;Refsnes&lt;/lastname&gt; &lt; age&gt;36&lt;/age&gt; &lt; dateborn&gt;1970-03-27&lt;/dateborn&gt; And here are the corresponding simple element definitions: &lt; xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt; xs:element name=&quot;age&quot; type=&quot;xs:integer&quot;/&gt; &lt; xs:element name=&quot;dateborn&quot; type=&quot;xs:date&quot;/&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 &quot;red&quot;: &lt; xs:element name=&quot;color&quot; type=&quot;xs:string&quot; default=&quot;red&quot;/&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 &quot;red&quot;: &lt; xs:element name=&quot;color&quot; type=&quot;xs:string&quot; fixed=&quot;red&quot;/&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, &quot;product&quot;, which is empty: &lt; product pid=&quot;1345&quot;/&gt; A complex XML element, &quot;employee&quot;, which contains only other elements: &lt; employee&gt; &lt; firstname&gt;John&lt;/firstname&gt; &lt; lastname&gt;Smith&lt;/lastname&gt; &lt; /employee&gt; A complex XML element, &quot;food&quot;, which contains only text: &lt; food type=&quot;dessert&quot;&gt;Ice cream&lt;/food&gt; A complex XML element, &quot;description&quot;, which contains both elements and text: &lt; description&gt; It happened on &lt;date lang=&quot;norwegian&quot;&gt;03.03.99&lt;/date&gt; .... &lt; /description&gt; How to Define a Complex Element Look at this complex XML element, &quot;employee&quot;, which contains only other elements: &lt; employee&gt; &lt; firstname&gt;John&lt;/firstname&gt; &lt; lastname&gt;Smith&lt;/lastname&gt; &lt; /employee&gt; We can define a complex element in an XML Schema two different ways: 1. The &quot;employee&quot; element can be declared directly by naming the element, like this: &lt; xs:element name=&quot;employee&quot;&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;firstname&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt; /xs:element&gt; If you use the method described above, only the &quot;employee&quot; element can use the specified complex type. Note that the child elements, &quot;firstname&quot; and &quot;lastname&quot;, are surrounded by the &lt;sequence&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 &quot;employee&quot; element can have a type attribute that refers to the name of the complex type to use: &lt; xs:element name=&quot;employee&quot; type=&quot;personinfo&quot;/&gt; &lt; xs:complexType name=&quot;personinfo&quot;&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;firstname&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:sequence&gt; &lt; /xs:complexType&gt; If you use the method described above, several elements can refer to the same complex type, like this: &lt; xs:element name=&quot;employee&quot; type=&quot;personinfo&quot;/&gt; &lt; xs:element name=&quot;student&quot; type=&quot;personinfo&quot;/&gt; &lt; xs:element name=&quot;member&quot; type=&quot;personinfo&quot;/&gt; &lt; xs:complexType name=&quot;personinfo&quot;&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;firstname&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:sequence&gt; &lt; /xs:complexType&gt; You can also base a complex element on an existing complex element and add some elements, like this: &lt; xs:element name=&quot;employee&quot; type=&quot;fullpersoninfo&quot;/&gt; &lt; xs:complexType name=&quot;personinfo&quot;&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;firstname&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:sequence&gt; &lt; /xs:complexType&gt; &lt; xs:complexType name=&quot;fullpersoninfo&quot;&gt; &lt;xs:complexContent&gt; &lt;xs:extension base=&quot;personinfo&quot;&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;address&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;city&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;country&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:sequence&gt; &lt;/xs:extension&gt; &lt;/xs:complexContent&gt; &lt; /xs:complexType&gt; Complex Types Containing Elements Only An XML element, &quot;person&quot;, that contains only other elements: &lt; person&gt; &lt; firstname&gt;John&lt;/firstname&gt; &lt; lastname&gt;Smith&lt;/lastname&gt; &lt; /person&gt; You can define the &quot;person&quot; element in a schema, like this: &lt; xs:element name=&quot;person&quot;&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;firstname&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt; /xs:element&gt; Notice the &lt;xs:sequence&gt; tag. It means that the elements defined (&quot;firstname&quot; and &quot;lastname&quot;) must appear in that order inside a &quot;person&quot; element. Or you can give the complexType element a name, and let the &quot;person&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): &lt; xs:element name=&quot;person&quot; type=&quot;persontype&quot;/&gt; &lt; xs:complexType name=&quot;persontype&quot;&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;firstname&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:sequence&gt; &lt; /xs:complexType&gt; Complex Types with Mixed Content An XML element, &quot;letter&quot;, that contains both text and other elements: &lt; letter&gt; Dear Mr.&lt;name&gt;John Smith&lt;/name&gt;. Your order &lt;orderid&gt;1032&lt;/orderid&gt; will be shipped on &lt;shipdate&gt;2001-07-13&lt;/shipdate&gt;. &lt; /letter&gt; The following schema declares the &quot;letter&quot; element: &lt; xs:element name=&quot;letter&quot;&gt; &lt;xs:complexType mixed=&quot;true&quot;&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;name&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;orderid&quot; type=&quot;xs:positiveInteger&quot;/&gt; &lt;xs:element name=&quot;shipdate&quot; type=&quot;xs:date&quot;/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt; /xs:element&gt; Note: To enable character data to appear between the child-elements of &quot;letter&quot;, the mixed attribute must be set to &quot;true&quot;. The &lt;xs:sequence&gt; tag means that the elements defined (name, orderid and shipdate) must appear in that order inside a &quot;letter&quot; element. We could also give the complexType element a name, and let the &quot;letter&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): &lt; xs:element name=&quot;letter&quot; type=&quot;lettertype&quot;/&gt; &lt; xs:complexType name=&quot;lettertype&quot; mixed=&quot;true&quot;&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;name&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;orderid&quot; type=&quot;xs:positiveInteger&quot;/&gt; &lt;xs:element name=&quot;shipdate&quot; type=&quot;xs:date&quot;/&gt; &lt;/xs:sequence&gt; &lt; /xs:complexType&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 &quot;33-657&quot;. The attribute named media has the value &quot;paper&quot;.
  4. Example Here is an XML element with an attribute: &lt; lastname lang=&quot;EN&quot;&gt;Smith&lt;/lastname&gt; And here is the corresponding attribute definition: &lt; xs:attribute name=&quot;lang&quot; type=&quot;xs:string&quot;/&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 &quot;EN&quot;: &lt; xs:attribute name=&quot;lang&quot; type=&quot;xs:string&quot; default=&quot;EN&quot;/&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 &quot;EN&quot;: &lt; xs:attribute name=&quot;lang&quot; type=&quot;xs:string&quot; fixed=&quot;EN&quot;/&gt; Optional and Required Attributes Attributes are optional by default. To specify that the attribute is required, use the &quot;use&quot; attribute: &lt; xs:attribute name=&quot;lang&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt; Restrictions on Content When an XML element or attribute has a data type defined, it puts restrictions on the element&apos;s or attribute&apos;s content. If an XML element is of type &quot;xs:date&quot; and contains a string like &quot;Hello World&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 &quot;car&quot; with a restriction. The only acceptable values are: Audi, Golf, BMW: &lt; xs:element name=&quot;car&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:enumeration value=&quot;Audi&quot;/&gt; &lt;xs:enumeration value=&quot;Golf&quot;/&gt; &lt;xs:enumeration value=&quot;BMW&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt; /xs:element&gt; The example above could also have been written like this: &lt; xs:element name=&quot;car&quot; type=&quot;carType&quot;/&gt; &lt; xs:simpleType name=&quot;carType&quot;&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:enumeration value=&quot;Audi&quot;/&gt; &lt;xs:enumeration value=&quot;Golf&quot;/&gt; &lt;xs:enumeration value=&quot;BMW&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; Note: In this case the type &quot;carType&quot; can be used by other elements because it is not a part of the &quot;car&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 &quot;letter&quot; with a restriction. The only acceptable value is ONE of the LOWERCASE letters from a to z: &lt; xs:element name=&quot;letter&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:pattern value=&quot;[a-z]&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&gt; The next example defines an element called &quot;initials&quot; with a restriction. The only acceptable value is THREE of the UPPERCASE letters from a to z: &lt; xs:element name=&quot;initials&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:pattern value=&quot;[A-Z][A-Z][A-Z]&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&gt; The next example also defines an element called &quot;initials&quot; with a restriction. The only acceptable value is THREE of the LOWERCASE OR UPPERCASE letters from a to z: &lt; xs:element name=&quot;initials&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:pattern value=&quot;[a-zA-Z][a-zA-Z][a-zA-Z]&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&gt; The next example defines an element called &quot;choice&quot; with a restriction. The only acceptable value is ONE of the following letters: x, y, OR z: &lt; xs:element name=&quot;choice&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:pattern value=&quot;[xyz]&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&gt; The next example defines an element called &quot;prodid&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: &lt; xs:element name=&quot;prodid&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:integer&quot;&gt; &lt;xs:pattern value=&quot;[0-9][0-9][0-9][0-9][0-9]&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&gt; Other Restrictions on a Series of Values The example below defines an element called &quot;letter&quot; with a restriction. The acceptable value is zero or more occurrences of lowercase letters from a to z: &lt; xs:element name=&quot;letter&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:pattern value=&quot;([a-z])*&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&gt; The next example also defines an element called &quot;letter&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, &quot;sToP&quot; will be validated by this pattern, but not &quot;Stop&quot; or &quot;STOP&quot; or &quot;stop&quot;: &lt; xs:element name=&quot;letter&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:pattern value=&quot;([a-z][A-Z])+&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&gt; The next example defines an element called &quot;gender&quot; with a restriction. The only acceptable value is male OR female: &lt; xs:element name=&quot;gender&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:pattern value=&quot;male|female&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&gt; The next example defines an element called &quot;password&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: &lt; xs:element name=&quot;password&quot;&gt; &lt; xs:simpleType&gt; &lt;xs:restriction base=&quot;xs:string&quot;&gt; &lt;xs:pattern value=&quot;[a-zA-Z0-9]{8}&quot;/&gt; &lt;/xs:restriction&gt; &lt; /xs:simpleType&gt; &lt;/xs:element&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 &quot;33-657&quot;. The attribute named media has the value &quot;paper&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 &quot;33-657&quot;. The attribute named media has the value &quot;paper&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&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 &lt;xs:element name=&quot;to&quot; type=&quot;xs:string&quot;/&gt; - is a simple element &lt;xs:element name=&quot;note&quot;&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 &lt;all&gt; indicator specifies that the child elements can appear in any order, and that each child element must occur only once: &lt; xs:element name=&quot;person&quot;&gt; &lt;xs:complexType&gt; &lt;xs:all&gt; &lt;xs:element name=&quot;firstname&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:all&gt; &lt;/xs:complexType&gt; &lt; /xs:element&gt; Note: When using the &lt;all&gt; indicator you can set the &lt;minOccurs&gt; indicator to 0 or 1 and the &lt;maxOccurs&gt; indicator can only be set to 1 (the &lt;minOccurs&gt; and &lt;maxOccurs&gt; are described later). Choice Indicator The &lt;choice&gt; indicator specifies that either one child element or another can occur: &lt; xs:element name=&quot;person&quot;&gt; &lt;xs:complexType&gt; &lt;xs:choice&gt; &lt;xs:element name=&quot;employee&quot; type=&quot;employee&quot;/&gt; &lt;xs:element name=&quot;member&quot; type=&quot;member&quot;/&gt; &lt;/xs:choice&gt; &lt;/xs:complexType&gt; &lt; /xs:element&gt; Sequence Indicator The &lt;sequence&gt; indicator specifies that the child elements must appear in a specific order: &lt; xs:element name=&quot;person&quot;&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;firstname&quot; type=&quot;xs:string&quot;/&gt; &lt;xs:element name=&quot;lastname&quot; type=&quot;xs:string&quot;/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt; /xs:element&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&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 &quot;expectations&quot; about the content. With XML Schemas, the sender can describe the data in a way that the receiver will understand. A date like: &quot;03-11-2004&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: &lt;date type=&quot;date&quot;&gt;2004-03-11&lt;/date&gt; ensures a mutual understanding of the content, because the XML data type &quot;date&quot; requires the format &quot;YYYY-MM-DD&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. &lt;?xml version=&quot;1.0&quot; encoding=&quot;WINDOWS-1251&quot;?&gt; &lt;?xml-stylesheet type=&apos;text/xsl&apos; href=&apos;ex01-1.xsl&apos;?&gt; &lt;tutorial&gt; &lt;title&gt;“Introduction to XML&quot;&lt;/title&gt; &lt;author&gt;Bob Hitch&lt;/author&gt; &lt;/tutorial&gt;