SlideShare a Scribd company logo
Validation – XML Schemas
Nguyễn Đăng Khoa
Content
• Document Type Definitions (DTDs)
• XML Schemas
XML Schemas (XSD)
• Define XML vocabularies and grammars
• Describe the structure and content of XML
documents in more detail than DTDs
• XML Schema 1.0 specifications were first
published by the W3C in 2001, with a second
edition following in 2004
• XML Schema 1.1 became a W3C
Recommendation in April 2012
XSD’s goals
• Check XML document is valid or not
XSD – Benefits
• Are created using basic XML
• Fully support the Namespace Recommendation
• Validate text element content based on built-in
and user-defined data types
• Create complex and reusable content models
• Enable the modeling of programming concepts
such as object inheritance and type substitution
XSD 1.0 - Specifications
• Part 1: Structures
(http://www.w3.org/TR/xmlschema-1/)
• Part 2: Datatypes
(http://www.w3.org/TR/xmlschema-2/)
XSD - Example
XSD – Namespace in XSD & XML
XSD – Explicitly namespace
XSD – Default namespace
XSD – XML doesn’t use namespace
URI to xsd
XSD – XML uses namespace
XSD – XML uses namespace
URI to xsdnamespace blank
XSD – XML uses namespace
XSD – XML uses namespace
XSD – Element and Attribute
qualification
XSD – qualified vs. unqualified
qualified
unqualified
XSD – Global vs. Local
Global
Local
XSD – Global vs. Local
• Global declarations are declarations that
appear as direct children of the <schema>
element. Global element declarations can be
reused throughout the XML Schema.
• Local declarations do not have the <schema>
element as their direct parent and can be
used only in their specific context.
XSD – elementFormDefault
• qualified: nested elements must belong to the
target namespace of the schema
• unqualified is default value, a mix of qualified
and unqualified elements
XSD – elementFormDefault – Example
Valid
XSD – elementFormDefault – Example
Invalid
Element 'first': This element is not expected. Expected is ({http://www.example.com/name}first)
XSD – elementFormDefault – Example
Valid
XSD – elementFormDefault – Example
Invalid
Element '{http://www.example.com/name}first': This element is not expected. Expected is (first)
XSD – attributeFormDefault – Example
• Is same elementFormDefault
• unqualified is default value
XSD – attributeFormDefault – Example
Valid
XSD – attributeFormDefault – Example
Invalid
XSD – attributeFormDefault – Example
Invalid
XSD – Content Models
• Is allowable content (type) of elements and
attributes
• There are 2 content models
– <complexType>
– <simpleType>
XSD - <complexType>
• Defines types that contain attributes or
elements
• There are 3 ways of interpreting a list of
elements
– <sequence>: Elements must appear in the given
order
– <choice>: Only one of the elements in the list may
appear
– <all>: Elements can appear in any order, with each
child element occurring zero or one time
XSD – <complexType> – Example
XSD – <complexType> – Example
XSD – Rule of <all>
• The <all> declaration must be the only content
model declaration that appears as a child of a
<complexType> definition
• The <all> declaration can contain only
<element> declarations as its children
– No <sequence>, <choice>, <group> in it
• The <all> declaration’s children may appear
once each in the instance document
XSD - <element>
XSD - <element> – Name
XSD - <element> – Type
XSD - <element> – Local Type
include the type
declaration as a child of
the element declaration
XSD - <element> – Global Type
XSD - <element> – Cardinality
XSD - <element> – Cardinality
Default: 1
XSD - <element> – Default value
XSD - <element> – Fixed value
XSD – Mixed Content
• Enable you to include both text and element
content within a single content model
XSD – Simple Content
• Enable you to include only text within a single
content model
XSD – Empty Content
XSD – Elements Wildcards
• Suppose you want to specify that your
element can contain any of the elements
declared in your namespace, or any elements
from another namespace
XSD – Elements Wildcards
List of namespace URIs
XSD – Elements Wildcards
indicate that any element from the schema’s target namespace can be
used
XSD – Elements Wildcards
indicate that elements not in any namespace can be used
XSD – Elements Wildcards
indicate that all elements from any namespace or no namespace are allowed
XSD – Elements Wildcards
indicate that elements from namespaces other than the schema’s
target namespace can be used
XSD – Elements Wildcards
(Default) Elements represented by this <any> element must be
declared. Furthermore, the element must be valid according to its
declaration
XSD – Elements Wildcards
Elements represented by this <any> element need not be declared in
the schema and need not be valid even if they are declared
XSD – Elements Wildcards
Elements represented by this <any> element must be validated if they
are declared, but must not be validated if they are declared
XSD – Elements Wildcards – Rules
• The <any> declaration can appear only within a content model.
• You are not allowed to create global <any> declarations
XSD – <group>
• Enable you to define reusable groups of
elements
XSD – Exercise - No namespace
XSD – Exercise – Use namespace
XSD - <attribute>
XSD - <attributeGroup>
• Enable you to define reusable groups of
attributes
XSD – Built-in Data Types
XSD – Built-in Data Types
XSD – Built-in Data Types
XSD – Built-in Data Types
XSD – Built-in Data Types
XSD – Built-in Data Types
• In addition to the types listed, the XML Schema
Recommendation also allows the types defined
within the XML Recommendation
– ID
– IDREF
– IDREFS
– ENTITY
– ENTITIES
– NOTATION
– NMTOKEN
– NMTOKENS
XSD – Exercise
XSD – User-Defined Data Types
• When you declare a <simpleType>, you must always
base your declaration on an existing data type
– Built-in
– Custom
• <simpleType> definitions are often called derived
types. There are three primary derived types:
– Restriction types
– List types
– Union types
XSD – User-Defined Data Types
prevent a simple type from being subtyped
XSD – Restriction Type
• is a subset of its base type
Facet
XSD – Restriction Type – Constraining
FacetsConstraint 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
Ref: http://www.w3schools.com/schema/schema_facets.asp
XSD – List Type
• create a list of items
XSD – Union Type
• allow potential values for elements and
attributes to have any of several types
XSD – Union Type

More Related Content

What's hot

Xml schema
Xml schemaXml schema
Xml schema
Harry Potter
 
XML Schema
XML SchemaXML Schema
XML Schema
yht4ever
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
Kumar
 
DTD
DTDDTD
DTD
Kumar
 
XML DTD and Schema
XML DTD and SchemaXML DTD and Schema
XML DTD and Schema
hamsa nandhini
 
Xml schema
Xml schemaXml schema
Xml schema
sana mateen
 
01 xml document structure
01 xml document structure01 xml document structure
01 xml document structure
Baskarkncet
 
Xml basics
Xml basicsXml basics
Xml basics
Kumar
 
Dtd
DtdDtd
Introduction to DTD
Introduction to DTDIntroduction to DTD
Introduction to DTD
torp42
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
Pradeep Rapolu
 
XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
videde_group
 
DTD
DTDDTD
Xml dtd
Xml dtdXml dtd
Xml dtd
sana mateen
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
Gtu Booker
 
fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
hamsa nandhini
 
00 introduction
00 introduction00 introduction
00 introduction
Baskarkncet
 
Xml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyXml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web Technology
Rajan Shah
 

What's hot (20)

Xml schema
Xml schemaXml schema
Xml schema
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
 
DTD
DTDDTD
DTD
 
Xsd
XsdXsd
Xsd
 
XML DTD and Schema
XML DTD and SchemaXML DTD and Schema
XML DTD and Schema
 
Xml schema
Xml schemaXml schema
Xml schema
 
01 xml document structure
01 xml document structure01 xml document structure
01 xml document structure
 
Xml basics
Xml basicsXml basics
Xml basics
 
Dtd
DtdDtd
Dtd
 
Introduction to DTD
Introduction to DTDIntroduction to DTD
Introduction to DTD
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
 
DTD
DTDDTD
DTD
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
 
00 introduction
00 introduction00 introduction
00 introduction
 
Xml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyXml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web Technology
 

Viewers also liked

XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for Perl
Geir Aalberg
 
Using JSON Schema Validator
Using JSON Schema ValidatorUsing JSON Schema Validator
Using JSON Schema Validator
Rahul Kumar
 
4 xml namespaces and xml schema
4   xml namespaces and xml schema4   xml namespaces and xml schema
4 xml namespaces and xml schema
gauravashq
 
GoOpen/Nordic Perl Workshop 2009
GoOpen/Nordic Perl Workshop 2009GoOpen/Nordic Perl Workshop 2009
GoOpen/Nordic Perl Workshop 2009
Geir Aalberg
 
JSON Referencing and Schema
JSON Referencing and SchemaJSON Referencing and Schema
JSON Referencing and Schemakriszyp
 
Julia language: inside the corporation
Julia language: inside the corporationJulia language: inside the corporation
Julia language: inside the corporation
Andre Pemmelaar
 
XML Schema (2002)
XML Schema (2002)XML Schema (2002)
XML Schema (2002)
Helder da Rocha
 
Weblogic Administration Managed Server migration
Weblogic Administration Managed Server migrationWeblogic Administration Managed Server migration
Weblogic Administration Managed Server migration
Rakesh Gujjarlapudi
 
Mule JSON Schema Validator
Mule JSON Schema ValidatorMule JSON Schema Validator
Mule JSON Schema Validator
Ankush Sharma
 
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schema
gauravashq
 
Enterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12cEnterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12c
Rakesh Gujjarlapudi
 
Oracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPSOracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPS
Rakesh Gujjarlapudi
 
Oracle BPM 11g Lesson 2
Oracle BPM 11g Lesson 2Oracle BPM 11g Lesson 2
Oracle BPM 11g Lesson 2
Rakesh Gujjarlapudi
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning Tutorial
Rakesh Gujjarlapudi
 
Oracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSMOracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSM
Rakesh Gujjarlapudi
 
Oracle OSB Tutorial 3
Oracle OSB Tutorial 3Oracle OSB Tutorial 3
Oracle OSB Tutorial 3
Rakesh Gujjarlapudi
 
Talking Services with Oracle ADF and Oracle SOA Suite
Talking Services with Oracle ADF and Oracle SOA SuiteTalking Services with Oracle ADF and Oracle SOA Suite
Talking Services with Oracle ADF and Oracle SOA Suite
DataNext Solutions
 
Osb student guide
Osb student guideOsb student guide
Osb student guide
Vibhor Rastogi
 

Viewers also liked (20)

XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for Perl
 
Using JSON Schema Validator
Using JSON Schema ValidatorUsing JSON Schema Validator
Using JSON Schema Validator
 
4 xml namespaces and xml schema
4   xml namespaces and xml schema4   xml namespaces and xml schema
4 xml namespaces and xml schema
 
GoOpen/Nordic Perl Workshop 2009
GoOpen/Nordic Perl Workshop 2009GoOpen/Nordic Perl Workshop 2009
GoOpen/Nordic Perl Workshop 2009
 
JSON Referencing and Schema
JSON Referencing and SchemaJSON Referencing and Schema
JSON Referencing and Schema
 
Julia language: inside the corporation
Julia language: inside the corporationJulia language: inside the corporation
Julia language: inside the corporation
 
XML Schema (2002)
XML Schema (2002)XML Schema (2002)
XML Schema (2002)
 
Weblogic Administration Managed Server migration
Weblogic Administration Managed Server migrationWeblogic Administration Managed Server migration
Weblogic Administration Managed Server migration
 
Mule JSON Schema Validator
Mule JSON Schema ValidatorMule JSON Schema Validator
Mule JSON Schema Validator
 
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schema
 
Enterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12cEnterprise managerclodcontrolinstallconfiguration emc12c
Enterprise managerclodcontrolinstallconfiguration emc12c
 
Oracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPSOracle WebLogic Server 11g for IT OPS
Oracle WebLogic Server 11g for IT OPS
 
Oracle BPM 11g Lesson 2
Oracle BPM 11g Lesson 2Oracle BPM 11g Lesson 2
Oracle BPM 11g Lesson 2
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning Tutorial
 
Oracle WebLogic 11g Topology
Oracle WebLogic 11g TopologyOracle WebLogic 11g Topology
Oracle WebLogic 11g Topology
 
Oracle BPM 11g Lesson 1
Oracle BPM 11g Lesson 1Oracle BPM 11g Lesson 1
Oracle BPM 11g Lesson 1
 
Oracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSMOracle OSB Security Enforcement with OWSM
Oracle OSB Security Enforcement with OWSM
 
Oracle OSB Tutorial 3
Oracle OSB Tutorial 3Oracle OSB Tutorial 3
Oracle OSB Tutorial 3
 
Talking Services with Oracle ADF and Oracle SOA Suite
Talking Services with Oracle ADF and Oracle SOA SuiteTalking Services with Oracle ADF and Oracle SOA Suite
Talking Services with Oracle ADF and Oracle SOA Suite
 
Osb student guide
Osb student guideOsb student guide
Osb student guide
 

Similar to XML's validation - XML Schema

XML SCHEMAS
XML SCHEMASXML SCHEMAS
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
Swati Parmar
 
SCDJWS 1. xml schema
SCDJWS 1. xml schemaSCDJWS 1. xml schema
SCDJWS 1. xml schema
Francesco Ierna
 
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
Ramco Institute of Technology, Rajapalayam, Tamilnadu, India
 
Xml part4
Xml part4Xml part4
Xml part4
NOHA AW
 
Xml 2
Xml  2 Xml  2
XML Schema.pptx
XML Schema.pptxXML Schema.pptx
XML Schema.pptx
JohnsonDcunha1
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
Harry Potter
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
James Wong
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
Young Alista
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
Tony Nguyen
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
Fraboni Ec
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
Hoang Nguyen
 
distributed system concerned lab sessions
distributed system concerned lab sessionsdistributed system concerned lab sessions
distributed system concerned lab sessions
milkesa13
 
advDBMS_XML.pptx
advDBMS_XML.pptxadvDBMS_XML.pptx
advDBMS_XML.pptx
IreneGetzi
 

Similar to XML's validation - XML Schema (20)

XML SCHEMAS
XML SCHEMASXML SCHEMAS
XML SCHEMAS
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
SCDJWS 1. xml schema
SCDJWS 1. xml schemaSCDJWS 1. xml schema
SCDJWS 1. xml schema
 
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 session
Xml sessionXml session
Xml session
 
Xml part4
Xml part4Xml part4
Xml part4
 
XML schemas
XML schemasXML schemas
XML schemas
 
Xml 2
Xml  2 Xml  2
Xml 2
 
XML Schema.pptx
XML Schema.pptxXML Schema.pptx
XML Schema.pptx
 
Xml
XmlXml
Xml
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
distributed system concerned lab sessions
distributed system concerned lab sessionsdistributed system concerned lab sessions
distributed system concerned lab sessions
 
Soap win
Soap winSoap win
Soap win
 
advDBMS_XML.pptx
advDBMS_XML.pptxadvDBMS_XML.pptx
advDBMS_XML.pptx
 

Recently uploaded

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
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
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
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
 
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
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 

Recently uploaded (20)

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
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
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
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
 
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
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 

XML's validation - XML Schema

  • 1. Validation – XML Schemas Nguyễn Đăng Khoa
  • 2. Content • Document Type Definitions (DTDs) • XML Schemas
  • 3. XML Schemas (XSD) • Define XML vocabularies and grammars • Describe the structure and content of XML documents in more detail than DTDs • XML Schema 1.0 specifications were first published by the W3C in 2001, with a second edition following in 2004 • XML Schema 1.1 became a W3C Recommendation in April 2012
  • 4. XSD’s goals • Check XML document is valid or not
  • 5. XSD – Benefits • Are created using basic XML • Fully support the Namespace Recommendation • Validate text element content based on built-in and user-defined data types • Create complex and reusable content models • Enable the modeling of programming concepts such as object inheritance and type substitution
  • 6. XSD 1.0 - Specifications • Part 1: Structures (http://www.w3.org/TR/xmlschema-1/) • Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/)
  • 8. XSD – Namespace in XSD & XML
  • 9. XSD – Explicitly namespace
  • 10. XSD – Default namespace
  • 11. XSD – XML doesn’t use namespace URI to xsd
  • 12. XSD – XML uses namespace
  • 13. XSD – XML uses namespace URI to xsdnamespace blank
  • 14. XSD – XML uses namespace
  • 15. XSD – XML uses namespace
  • 16. XSD – Element and Attribute qualification
  • 17. XSD – qualified vs. unqualified qualified unqualified
  • 18. XSD – Global vs. Local Global Local
  • 19. XSD – Global vs. Local • Global declarations are declarations that appear as direct children of the <schema> element. Global element declarations can be reused throughout the XML Schema. • Local declarations do not have the <schema> element as their direct parent and can be used only in their specific context.
  • 20. XSD – elementFormDefault • qualified: nested elements must belong to the target namespace of the schema • unqualified is default value, a mix of qualified and unqualified elements
  • 21. XSD – elementFormDefault – Example Valid
  • 22. XSD – elementFormDefault – Example Invalid Element 'first': This element is not expected. Expected is ({http://www.example.com/name}first)
  • 23. XSD – elementFormDefault – Example Valid
  • 24. XSD – elementFormDefault – Example Invalid Element '{http://www.example.com/name}first': This element is not expected. Expected is (first)
  • 25. XSD – attributeFormDefault – Example • Is same elementFormDefault • unqualified is default value
  • 26. XSD – attributeFormDefault – Example Valid
  • 27. XSD – attributeFormDefault – Example Invalid
  • 28. XSD – attributeFormDefault – Example Invalid
  • 29. XSD – Content Models • Is allowable content (type) of elements and attributes • There are 2 content models – <complexType> – <simpleType>
  • 30. XSD - <complexType> • Defines types that contain attributes or elements • There are 3 ways of interpreting a list of elements – <sequence>: Elements must appear in the given order – <choice>: Only one of the elements in the list may appear – <all>: Elements can appear in any order, with each child element occurring zero or one time
  • 31. XSD – <complexType> – Example
  • 32. XSD – <complexType> – Example
  • 33. XSD – Rule of <all> • The <all> declaration must be the only content model declaration that appears as a child of a <complexType> definition • The <all> declaration can contain only <element> declarations as its children – No <sequence>, <choice>, <group> in it • The <all> declaration’s children may appear once each in the instance document
  • 35. XSD - <element> – Name
  • 36. XSD - <element> – Type
  • 37. XSD - <element> – Local Type include the type declaration as a child of the element declaration
  • 38. XSD - <element> – Global Type
  • 39. XSD - <element> – Cardinality
  • 40. XSD - <element> – Cardinality Default: 1
  • 41. XSD - <element> – Default value
  • 42. XSD - <element> – Fixed value
  • 43. XSD – Mixed Content • Enable you to include both text and element content within a single content model
  • 44. XSD – Simple Content • Enable you to include only text within a single content model
  • 45. XSD – Empty Content
  • 46. XSD – Elements Wildcards • Suppose you want to specify that your element can contain any of the elements declared in your namespace, or any elements from another namespace
  • 47. XSD – Elements Wildcards List of namespace URIs
  • 48. XSD – Elements Wildcards indicate that any element from the schema’s target namespace can be used
  • 49. XSD – Elements Wildcards indicate that elements not in any namespace can be used
  • 50. XSD – Elements Wildcards indicate that all elements from any namespace or no namespace are allowed
  • 51. XSD – Elements Wildcards indicate that elements from namespaces other than the schema’s target namespace can be used
  • 52. XSD – Elements Wildcards (Default) Elements represented by this <any> element must be declared. Furthermore, the element must be valid according to its declaration
  • 53. XSD – Elements Wildcards Elements represented by this <any> element need not be declared in the schema and need not be valid even if they are declared
  • 54. XSD – Elements Wildcards Elements represented by this <any> element must be validated if they are declared, but must not be validated if they are declared
  • 55. XSD – Elements Wildcards – Rules • The <any> declaration can appear only within a content model. • You are not allowed to create global <any> declarations
  • 56. XSD – <group> • Enable you to define reusable groups of elements
  • 57. XSD – Exercise - No namespace
  • 58. XSD – Exercise – Use namespace
  • 60. XSD - <attributeGroup> • Enable you to define reusable groups of attributes
  • 61. XSD – Built-in Data Types
  • 62. XSD – Built-in Data Types
  • 63. XSD – Built-in Data Types
  • 64. XSD – Built-in Data Types
  • 65. XSD – Built-in Data Types
  • 66. XSD – Built-in Data Types • In addition to the types listed, the XML Schema Recommendation also allows the types defined within the XML Recommendation – ID – IDREF – IDREFS – ENTITY – ENTITIES – NOTATION – NMTOKEN – NMTOKENS
  • 68. XSD – User-Defined Data Types • When you declare a <simpleType>, you must always base your declaration on an existing data type – Built-in – Custom • <simpleType> definitions are often called derived types. There are three primary derived types: – Restriction types – List types – Union types
  • 69. XSD – User-Defined Data Types prevent a simple type from being subtyped
  • 70. XSD – Restriction Type • is a subset of its base type Facet
  • 71. XSD – Restriction Type – Constraining FacetsConstraint 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 Ref: http://www.w3schools.com/schema/schema_facets.asp
  • 72. XSD – List Type • create a list of items
  • 73. XSD – Union Type • allow potential values for elements and attributes to have any of several types

Editor's Notes

  1. XML trong OOP
  2. They describe the structure and content of XML documents in more detail than DTDsXML Schemas are a mature technology used in a variety of XML applications.Apart from their use in validation, aspects of XML Schemas are used in various other XMLtechnologies such as XQuery and SOAP
  3. XSD is xml
  4. XSD is xml
  5. XSD is xml
  6. XSD is xml
  7. XSD is xml
  8. XSD is xml
  9. XSD is xml
  10. ERROR: Element &apos;first&apos;: This element is not expected. Expected is ( {http://www.example.com/name}first ).
  11. ERROR: Element &apos;{http://www.example.com/name}first&apos;: This element is not expected. Expected is ( first ).
  12. Attribute just use &lt;simpleType&gt;
  13. Even though the type is global, it is still part of the target namespace. Therefore, when referring to the type, you must include the target namespace prefix (if any). This example used the prefix target to refer to the target namespace
  14. maxOccurs must be greater than or equal to the value for minOccursyou may want to reuse entire element declarations instead of just the type
  15. maxOccurs must be greater than or equal to the value for minOccursyou may want to reuse entire element declarations instead of just the type
  16. maxOccurs must be greater than or equal to the value for minOccurs
  17. maxOccurs must be greater than or equal to the value for minOccurs
  18. To declare an empty content model in a &lt;complexType&gt; definition, you simply create the&lt;complexType&gt; definition without any &lt;element&gt; or content model declarations.
  19. ##any Enables elements from all namespaces to be included as part of the wildcard.##other Enables elements from namespaces other than the targetNamespace to be included as part of the wildcard.##targetNamespace Enables elements from only the targetNamespace to be included as part of the wildcard.##local Enables any well-formed elements that are not qualified by a namespace to be included as part of the wildcard.Whitespace-separated Enables elements from any listed namespaces to be included as part of the list of allowable wildcards. Possible list values also include ##targetNamespace namespace URIs and ##local
  20. Because you must derive every &lt;simpleType&gt; definition from another data type, A simpleType declaration contained within a complexType or attribute element defines that simple type within the scope of the complexType or attribute that contains it. If a simpleType declaration has the schema element as its parent, it has global scope within that schema.
  21. The final attribute can be used to prevent a simple type from being subtyped. If finalcontains the value list, the type cannot be extended by listing. If final contains thevalue restriction, the type cannot be extended by restriction. If final contains thevalue union, the type cannot become a member of a union. These three values can becombined in a whitespace-separated list. For instance, final=&quot;list union&quot; preventsderivation by list and union but not by restriction. If final has the value #all, the typecannot be used as a base type in any way.
  22. EnumerationsNumeric (http://msdn.microsoft.com/en-us/library/ms256050(v=vs.110).aspx)LengthForcing pattern
  23.  a simple type (listOfDates) that allows a list of dates (each list item date must be separated by white space) as its contents.http://msdn.microsoft.com/en-us/library/ms256050(v=vs.110).aspx
  24. The value of the memberTypes attribute should be a whitespaceseparatedlist of references to global &lt;simpleType&gt; definitions or built-in XML Schema datatypes
  25. http://msdn.microsoft.com/en-us/library/ms256050(v=vs.110).aspx