SlideShare a Scribd company logo
XSD
Incomplete Overview
A Simple XML Document
Look at this simple XML document called "note.xml":

<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
An XML Schema
The following example is an XML Schema file called "note.xsd" that defines the
elements of the XML document above ("note.xml"):
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string“ maxOccours=“4” />
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:strincoug"/>
<xs:element name="body" type="xs:string“ minOccours=“0”/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Simple Element vs Complex Element
Reference to an XML Schema
A Reference to an XML Schema
This XML document has a reference to an XML Schema:
<?xml version="1.0"?>
<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
The <schema> Element
The <schema> element is the root element of
every XML Schema:
<?xml version="1.0"?>
<xs:schema>
...
...
</xs:schema>
Simple Element
What is a Simple Element?
A simple element is an XML element that can contain only
text. It cannot contain any other elements or attributes.
However, the "only text" 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:
<xs:element name="xxx" type="yyy"/>
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:
<lastname>Refsnes</lastname>
<age>36</age>
<dateborn>1970-03-27</dateborn>
And here are the corresponding simple element definitions:
<xs:element name="lastname" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="dateborn" type="xs:date"/>
Attribute
What is an 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.
How to Define an Attribute?
The syntax for defining an attribute is:
<xs:attribute name="xxx" type="yyy"/>
where xxx is the name of the attribute and yyy specifies the data type of the attribute.
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 is an XML element with an attribute:
<lastname lang="EN">Smith</lastname>
And here is the corresponding attribute
definition:
<xs:attribute name="lang" type="xs:string"/>
Optional and Required Attributes
Attributes are optional by default. To specify
that the attribute is required, use the "use"
attribute:
<xs:attribute name="lang" type="xs:string"
use="required"/>
Restrictions on Values
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>
Restrictions on a Set of Values
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 "car" with a restriction.
The only acceptable values are: Audi, Golf, BMW:
<xs:element name="car">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Restrictions on a Series of Values
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 "letter" with a
restriction. The only acceptable value is ONE of the LOWERCASE letters
from a to z:
<xs:element name="letter">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-z]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Restrictions for Datatypes
Constraint

Description

enumeration

Defines a list of acceptable values

fractionDigits

Specifies the maximum number of decimal places allowed. Must be equal to or greater
than zero

length

Specifies the exact number of characters or list items allowed. Must be equal to or greater
than zero

maxExclusive

Specifies the upper bounds for numeric values (the value must be less than this value)

maxInclusive

Specifies the upper bounds for numeric values (the value must be less than or equal to
this value)

maxLength

Specifies the maximum number of characters or list items allowed. Must be equal to or
greater than zero

minExclusive

Specifies the lower bounds for numeric values (the value must be greater than this value)

minInclusive

Specifies the lower bounds for numeric values (the value must be greater than or equal to
this value)

minLength

Specifies the minimum number of characters or list items allowed. Must be equal to or
greater than zero

pattern

Defines the exact sequence of characters that are acceptable

totalDigits

Specifies the exact number of digits allowed. Must be greater than zero

whiteSpace

Specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled
Complex Element
What is a Complex Element?
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

Note: Each of these elements may contain attributes as well!
Examples of Complex Elements
A complex XML element, "product", which is empty:

<product pid="1345"/>
A complex XML element, "employee", which contains only other elements:

<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
A complex XML element, "food", which contains only text:

<food type="dessert">Ice cream</food>
A complex XML element, "description", which contains both elements and text:

<description>
It happened on <date lang="norwegian">03.03.99</date> ....
</description>
How to Define a Complex Element
Look at this complex XML element, "employee", which contains only other elements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
We can define a complex element in an XML Schema two different ways:
The "employee" element can be declared directly by naming the element, like this:
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xsd:unique> Element
<xs:unique name="testUnique">
<xs:selector xpath="book"/>
<xs:field xpath="title"/>
</xs:unique>
<xs:element name="books">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="book"/>
</xs:sequence>

</xs:complexType>
<xs:unique name="testUnique">
<xs:selector xpath="book"/>
<xs:field xpath="title"/>

</xs:unique>

</xs:element>
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
</xs:sequence>

</xs:complexType>
</xs:element>

More Related Content

What's hot

fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
hamsa nandhini
 
Xml schema
Xml schemaXml schema
Xml schema
sana mateen
 
Xml part4
Xml part4Xml part4
Xml part4
NOHA AW
 
Xml schema
Xml schemaXml schema
Xml schema
Harry Potter
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
Abhishek Kesharwani
 
Xsd examples
Xsd examplesXsd examples
Xsd examples
Bình Trọng Án
 
Xsd tutorial
Xsd tutorialXsd tutorial
Xsd tutorial
Ashoka Vanjare
 
Xml
Xml Xml
Xml Schema
Xml SchemaXml Schema
Xml Schema
vikram singh
 
XML Schemas
XML SchemasXML Schemas
XML Schemas
People Strategists
 
Xsd
XsdXsd
Xml intro1
Xml intro1Xml intro1
Xml
Xml Xml
02 xml schema
02 xml schema02 xml schema
02 xml schema
Baskarkncet
 
Xml schema
Xml schemaXml schema
Xml schema
Akshaya Akshaya
 
Xml
XmlXml
Xslt
XsltXslt
Xml p5 Lecture Notes
Xml p5 Lecture NotesXml p5 Lecture Notes
Xml p5 Lecture Notes
Santhiya Grace
 
Xml part2
Xml part2Xml part2
Xml part2
NOHA AW
 

What's hot (19)

fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
 
Xml schema
Xml schemaXml schema
Xml schema
 
Xml part4
Xml part4Xml part4
Xml part4
 
Xml schema
Xml schemaXml schema
Xml schema
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
Xsd examples
Xsd examplesXsd examples
Xsd examples
 
Xsd tutorial
Xsd tutorialXsd tutorial
Xsd tutorial
 
Xml
Xml Xml
Xml
 
Xml Schema
Xml SchemaXml Schema
Xml Schema
 
XML Schemas
XML SchemasXML Schemas
XML Schemas
 
Xsd
XsdXsd
Xsd
 
Xml intro1
Xml intro1Xml intro1
Xml intro1
 
Xml
Xml Xml
Xml
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
 
Xml schema
Xml schemaXml schema
Xml schema
 
Xml
XmlXml
Xml
 
Xslt
XsltXslt
Xslt
 
Xml p5 Lecture Notes
Xml p5 Lecture NotesXml p5 Lecture Notes
Xml p5 Lecture Notes
 
Xml part2
Xml part2Xml part2
Xml part2
 

Similar to XSD Incomplete Overview Draft

Xsd
XsdXsd
XML Fundamentals
XML FundamentalsXML Fundamentals
Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
Xsd restrictions, xsl elements, dhtml
Xsd restrictions, xsl elements, dhtmlXsd restrictions, xsl elements, dhtml
Xsd restrictions, xsl elements, dhtml
AMIT VIRAMGAMI
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
Pradeep Rapolu
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
Swati Parmar
 
XML SCHEMAS
XML SCHEMASXML SCHEMAS
XML Schema
XML SchemaXML Schema
XML Schema
yht4ever
 
XML
XMLXML
Xml
XmlXml
XML
XMLXML
SCDJWS 1. xml schema
SCDJWS 1. xml schemaSCDJWS 1. xml schema
SCDJWS 1. xml schema
Francesco Ierna
 
paper about xml
paper about xmlpaper about xml
XML - The Extensible Markup Language
XML - The Extensible Markup LanguageXML - The Extensible Markup Language
XML - The Extensible Markup Language
Gujarat Technological University
 
Xml processing in scala
Xml processing in scalaXml processing in scala
Xml processing in scala
Knoldus Inc.
 
Xml processing in scala
Xml processing in scalaXml processing in scala
Xml processing in scala
Neelkanth Sachdeva
 
XML_schema_Structure
XML_schema_StructureXML_schema_Structure
XML_schema_Structure
Vijay Kumar Verma
 
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriyaIPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
VijiPriya Jeyamani
 
Web Information Systems XML
Web Information Systems XMLWeb Information Systems XML
Web Information Systems XML
Artificial Intelligence Institute at UofSC
 
Soap win
Soap winSoap win

Similar to XSD Incomplete Overview Draft (20)

Xsd
XsdXsd
Xsd
 
XML Fundamentals
XML FundamentalsXML Fundamentals
XML Fundamentals
 
Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
Schemas 2 - Restricting Values
 
Xsd restrictions, xsl elements, dhtml
Xsd restrictions, xsl elements, dhtmlXsd restrictions, xsl elements, dhtml
Xsd restrictions, xsl elements, dhtml
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
XML SCHEMAS
XML SCHEMASXML SCHEMAS
XML SCHEMAS
 
XML Schema
XML SchemaXML Schema
XML Schema
 
XML
XMLXML
XML
 
Xml
XmlXml
Xml
 
XML
XMLXML
XML
 
SCDJWS 1. xml schema
SCDJWS 1. xml schemaSCDJWS 1. xml schema
SCDJWS 1. xml schema
 
paper about xml
paper about xmlpaper about xml
paper about xml
 
XML - The Extensible Markup Language
XML - The Extensible Markup LanguageXML - The Extensible Markup Language
XML - The Extensible Markup Language
 
Xml processing in scala
Xml processing in scalaXml processing in scala
Xml processing in scala
 
Xml processing in scala
Xml processing in scalaXml processing in scala
Xml processing in scala
 
XML_schema_Structure
XML_schema_StructureXML_schema_Structure
XML_schema_Structure
 
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriyaIPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
 
Web Information Systems XML
Web Information Systems XMLWeb Information Systems XML
Web Information Systems XML
 
Soap win
Soap winSoap win
Soap win
 

More from Pedro De Almeida

APM Model in .NET - PT-pt
APM Model in .NET - PT-ptAPM Model in .NET - PT-pt
APM Model in .NET - PT-pt
Pedro De Almeida
 
Java memory model primary ref. - faq
Java memory model   primary ref. - faqJava memory model   primary ref. - faq
Java memory model primary ref. - faq
Pedro De Almeida
 
Sistemas Operativos - Processos e Threads
Sistemas Operativos - Processos e ThreadsSistemas Operativos - Processos e Threads
Sistemas Operativos - Processos e Threads
Pedro De Almeida
 
IP Multicast Routing
IP Multicast RoutingIP Multicast Routing
IP Multicast Routing
Pedro De Almeida
 
O Projecto, Gestão de Projectos e o Gestor de Projectos - Parte 1
O Projecto, Gestão de Projectos e o Gestor de Projectos - Parte 1O Projecto, Gestão de Projectos e o Gestor de Projectos - Parte 1
O Projecto, Gestão de Projectos e o Gestor de Projectos - Parte 1
Pedro De Almeida
 
Validation of a credit card number
Validation of a credit card numberValidation of a credit card number
Validation of a credit card number
Pedro De Almeida
 
Classes e Objectos JAVA
Classes e Objectos JAVAClasses e Objectos JAVA
Classes e Objectos JAVA
Pedro De Almeida
 
Ficheiros em JAVA
Ficheiros em JAVAFicheiros em JAVA
Ficheiros em JAVA
Pedro De Almeida
 
Excepções JAVA
Excepções JAVAExcepções JAVA
Excepções JAVA
Pedro De Almeida
 
Sessão 10 Códigos Cíclicos
Sessão 10 Códigos CíclicosSessão 10 Códigos Cíclicos
Sessão 10 Códigos Cíclicos
Pedro De Almeida
 
Sessao 9 Capacidade de canal e Introdução a Codificação de canal
Sessao 9 Capacidade de canal e Introdução a Codificação de canalSessao 9 Capacidade de canal e Introdução a Codificação de canal
Sessao 9 Capacidade de canal e Introdução a Codificação de canal
Pedro De Almeida
 
Sessão 8 Codificação Lempel-Ziv
Sessão 8 Codificação Lempel-ZivSessão 8 Codificação Lempel-Ziv
Sessão 8 Codificação Lempel-Ziv
Pedro De Almeida
 
Sessao 7 Fontes com memória e codificação aritmética
Sessao 7 Fontes com memória e codificação aritméticaSessao 7 Fontes com memória e codificação aritmética
Sessao 7 Fontes com memória e codificação aritmética
Pedro De Almeida
 
Sessao 5 Redundância e introdução à codificação de fonte
Sessao 5 Redundância e introdução à codificação de fonteSessao 5 Redundância e introdução à codificação de fonte
Sessao 5 Redundância e introdução à codificação de fonte
Pedro De Almeida
 
Sessão 6 codificadores estatísticos
Sessão 6 codificadores estatísticosSessão 6 codificadores estatísticos
Sessão 6 codificadores estatísticos
Pedro De Almeida
 
Sessao 4 - Chaves espúrias e distância de unicidade
Sessao 4 - Chaves espúrias e distância de unicidadeSessao 4 - Chaves espúrias e distância de unicidade
Sessao 4 - Chaves espúrias e distância de unicidade
Pedro De Almeida
 
Sessao 3 Informação mútua e equívocos
Sessao 3 Informação mútua e equívocosSessao 3 Informação mútua e equívocos
Sessao 3 Informação mútua e equívocos
Pedro De Almeida
 
Sessao 2 Introdução à T.I e Entropias
Sessao 2 Introdução à T.I e EntropiasSessao 2 Introdução à T.I e Entropias
Sessao 2 Introdução à T.I e Entropias
Pedro De Almeida
 
Cripto - Introdução, probabilidades e Conceito de Segurança
Cripto - Introdução, probabilidades e Conceito de SegurançaCripto - Introdução, probabilidades e Conceito de Segurança
Cripto - Introdução, probabilidades e Conceito de Segurança
Pedro De Almeida
 
Basic java tutorial
Basic java tutorialBasic java tutorial
Basic java tutorial
Pedro De Almeida
 

More from Pedro De Almeida (20)

APM Model in .NET - PT-pt
APM Model in .NET - PT-ptAPM Model in .NET - PT-pt
APM Model in .NET - PT-pt
 
Java memory model primary ref. - faq
Java memory model   primary ref. - faqJava memory model   primary ref. - faq
Java memory model primary ref. - faq
 
Sistemas Operativos - Processos e Threads
Sistemas Operativos - Processos e ThreadsSistemas Operativos - Processos e Threads
Sistemas Operativos - Processos e Threads
 
IP Multicast Routing
IP Multicast RoutingIP Multicast Routing
IP Multicast Routing
 
O Projecto, Gestão de Projectos e o Gestor de Projectos - Parte 1
O Projecto, Gestão de Projectos e o Gestor de Projectos - Parte 1O Projecto, Gestão de Projectos e o Gestor de Projectos - Parte 1
O Projecto, Gestão de Projectos e o Gestor de Projectos - Parte 1
 
Validation of a credit card number
Validation of a credit card numberValidation of a credit card number
Validation of a credit card number
 
Classes e Objectos JAVA
Classes e Objectos JAVAClasses e Objectos JAVA
Classes e Objectos JAVA
 
Ficheiros em JAVA
Ficheiros em JAVAFicheiros em JAVA
Ficheiros em JAVA
 
Excepções JAVA
Excepções JAVAExcepções JAVA
Excepções JAVA
 
Sessão 10 Códigos Cíclicos
Sessão 10 Códigos CíclicosSessão 10 Códigos Cíclicos
Sessão 10 Códigos Cíclicos
 
Sessao 9 Capacidade de canal e Introdução a Codificação de canal
Sessao 9 Capacidade de canal e Introdução a Codificação de canalSessao 9 Capacidade de canal e Introdução a Codificação de canal
Sessao 9 Capacidade de canal e Introdução a Codificação de canal
 
Sessão 8 Codificação Lempel-Ziv
Sessão 8 Codificação Lempel-ZivSessão 8 Codificação Lempel-Ziv
Sessão 8 Codificação Lempel-Ziv
 
Sessao 7 Fontes com memória e codificação aritmética
Sessao 7 Fontes com memória e codificação aritméticaSessao 7 Fontes com memória e codificação aritmética
Sessao 7 Fontes com memória e codificação aritmética
 
Sessao 5 Redundância e introdução à codificação de fonte
Sessao 5 Redundância e introdução à codificação de fonteSessao 5 Redundância e introdução à codificação de fonte
Sessao 5 Redundância e introdução à codificação de fonte
 
Sessão 6 codificadores estatísticos
Sessão 6 codificadores estatísticosSessão 6 codificadores estatísticos
Sessão 6 codificadores estatísticos
 
Sessao 4 - Chaves espúrias e distância de unicidade
Sessao 4 - Chaves espúrias e distância de unicidadeSessao 4 - Chaves espúrias e distância de unicidade
Sessao 4 - Chaves espúrias e distância de unicidade
 
Sessao 3 Informação mútua e equívocos
Sessao 3 Informação mútua e equívocosSessao 3 Informação mútua e equívocos
Sessao 3 Informação mútua e equívocos
 
Sessao 2 Introdução à T.I e Entropias
Sessao 2 Introdução à T.I e EntropiasSessao 2 Introdução à T.I e Entropias
Sessao 2 Introdução à T.I e Entropias
 
Cripto - Introdução, probabilidades e Conceito de Segurança
Cripto - Introdução, probabilidades e Conceito de SegurançaCripto - Introdução, probabilidades e Conceito de Segurança
Cripto - Introdução, probabilidades e Conceito de Segurança
 
Basic java tutorial
Basic java tutorialBasic java tutorial
Basic java tutorial
 

Recently uploaded

Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 

Recently uploaded (20)

Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 

XSD Incomplete Overview Draft

  • 2. A Simple XML Document Look at this simple XML document called "note.xml": <?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 3. An XML Schema The following example is an XML Schema file called "note.xsd" that defines the elements of the XML document above ("note.xml"): <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string“ maxOccours=“4” /> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:strincoug"/> <xs:element name="body" type="xs:string“ minOccours=“0”/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Simple Element vs Complex Element
  • 4. Reference to an XML Schema A Reference to an XML Schema This XML document has a reference to an XML Schema: <?xml version="1.0"?> <note xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com note.xsd"> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 5. The <schema> Element The <schema> element is the root element of every XML Schema: <?xml version="1.0"?> <xs:schema> ... ... </xs:schema>
  • 6. Simple Element What is a Simple Element? A simple element is an XML element that can contain only text. It cannot contain any other elements or attributes. However, the "only text" 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.
  • 7. The syntax for defining a simple element is: <xs:element name="xxx" type="yyy"/> 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
  • 8. Example Here are some XML elements: <lastname>Refsnes</lastname> <age>36</age> <dateborn>1970-03-27</dateborn> And here are the corresponding simple element definitions: <xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <xs:element name="dateborn" type="xs:date"/>
  • 9. Attribute What is an 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. How to Define an Attribute? The syntax for defining an attribute is: <xs:attribute name="xxx" type="yyy"/> where xxx is the name of the attribute and yyy specifies the data type of the attribute. 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
  • 10. Example Here is an XML element with an attribute: <lastname lang="EN">Smith</lastname> And here is the corresponding attribute definition: <xs:attribute name="lang" type="xs:string"/>
  • 11. Optional and Required Attributes Attributes are optional by default. To specify that the attribute is required, use the "use" attribute: <xs:attribute name="lang" type="xs:string" use="required"/>
  • 12. Restrictions on Values 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>
  • 13. Restrictions on a Set of Values 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 "car" with a restriction. The only acceptable values are: Audi, Golf, BMW: <xs:element name="car"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Audi"/> <xs:enumeration value="Golf"/> <xs:enumeration value="BMW"/> </xs:restriction> </xs:simpleType> </xs:element>
  • 14. Restrictions on a Series of Values 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 "letter" with a restriction. The only acceptable value is ONE of the LOWERCASE letters from a to z: <xs:element name="letter"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[a-z]"/> </xs:restriction> </xs:simpleType> </xs:element>
  • 15. Restrictions for Datatypes Constraint Description enumeration Defines a list of acceptable values fractionDigits Specifies the maximum number of decimal places allowed. Must be equal to or greater than zero length Specifies the exact number of characters or list items allowed. Must be equal to or greater than zero maxExclusive Specifies the upper bounds for numeric values (the value must be less than this value) maxInclusive Specifies the upper bounds for numeric values (the value must be less than or equal to this value) maxLength Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero minExclusive Specifies the lower bounds for numeric values (the value must be greater than this value) minInclusive Specifies the lower bounds for numeric values (the value must be greater than or equal to this value) minLength Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero pattern Defines the exact sequence of characters that are acceptable totalDigits Specifies the exact number of digits allowed. Must be greater than zero whiteSpace Specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled
  • 16. Complex Element What is a Complex Element? 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 Note: Each of these elements may contain attributes as well!
  • 17. Examples of Complex Elements A complex XML element, "product", which is empty: <product pid="1345"/> A complex XML element, "employee", which contains only other elements: <employee> <firstname>John</firstname> <lastname>Smith</lastname> </employee> A complex XML element, "food", which contains only text: <food type="dessert">Ice cream</food> A complex XML element, "description", which contains both elements and text: <description> It happened on <date lang="norwegian">03.03.99</date> .... </description>
  • 18. How to Define a Complex Element Look at this complex XML element, "employee", which contains only other elements: <employee> <firstname>John</firstname> <lastname>Smith</lastname> </employee> We can define a complex element in an XML Schema two different ways: The "employee" element can be declared directly by naming the element, like this: <xs:element name="employee"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
  • 19. <xsd:unique> Element <xs:unique name="testUnique"> <xs:selector xpath="book"/> <xs:field xpath="title"/> </xs:unique>
  • 20. <xs:element name="books"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="book"/> </xs:sequence> </xs:complexType> <xs:unique name="testUnique"> <xs:selector xpath="book"/> <xs:field xpath="title"/> </xs:unique> </xs:element>
  • 21. <xs:element name="book"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>