SlideShare a Scribd company logo
XML SCHEMAS
Tutorial 4
LIMITATION OF DTD
• DTD has limitation on the number of data type can be used.
• Can not recognize the namespace.
SCHEMAS
● A schema is an XML document that defines the content and structure of one or
more XML documents.
● The XML document that will be validated is called the instance document.
● Why Use an XML Schema?
● With XML Schema, your XML files can carry a description of its own
format.
COMPARING SCHEMASAND DTDS
XML SCHEMA V.S DTD
• XML Schemas are More Powerful than DTD:
• XML Schemas are written in XML.
• XML Schema supports a collection of built-in data types and allows
programmers to define their own data types.
• XML Schemas support data types.
• XML Schemas support namespaces.
STARTING A SCHEMA FILE
• A schema is always placed in a separate XML document that is referenced
by the instance document.
• A file written in XML Schema has the extension .xsd
• Since the Schema file is actually an XML file, it must start with an XML
declaration.
• The root element in any XML Schema document is the schema element ,
and it must declare a namespace for the XML Schema.
<?xml version=“1.0” encoding=“UTF=8”?>
<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”>
schema content
</xs:schema>
ELEMENTSANDATTRIBUTES OFTHE PATIENTS DOCUMENT
SCHEMATYPES
XML Schema recognize two categories of element types that are:
1. A complex type element has one or more attributes, or is the parent to one or more child
elements.
2. A simple type element contains only character data and has no attributes.
SCHEMATYPES
ELEMENTSANDATTRIBUTES OFTHE PATIENTS DOCUMENT
1- SIMPLE TYPE
ELEMENTS
SIMPLE TYPE ELEMENTS
• Use the following syntax to declare a simple type element in XML Schema:
<xs:element name=“name” type =“xs:type”/>
● Here, name is the name of the element in the instance document and type
is the datatype of the element.
● XML Schema tags must be qualified with the namespace prefix.
DECLARINGANATTRIBUTE
• An attribute is always a simple type. The syntax to define an attribute is
<xs:attribute name="name" type="xs:type” />
• Where name is the name of the attribute and type is the data type.
• You can also define a default value and a fixed value for the attribute:
<xs:attribute name="name" type="xs:type” default=“default value”
fixed=“fixed value" />
• The default and fixed attributes are optional.
* notice that we did not specify which element the attribute belongs to
2- COMPLEX TYPE
ELEMENTS
COMPLEX TYPE ELEMENTS
The basic structure for defining a complex type element with XML Schema is
<xs:element name="name">
<xs:complexType>
declarations
</xs:complexType>
</xs:element>
Where name is the name of the element and declarations are the declarations of the child elements or attributes
associated with the element.
COMPLEX TYPE ELEMENTS
Five complex type elements that usually appear in an instance document are
the following:
1–The element is an empty element and contains attributes only.
2–The element contains child elements only.
3–The element contains both child elements and attributes.
4–The element contains both child elements and text.
5–The element contains both attributes and text but no child element.
1- ELEMENTS WITHATTRIBUTES ONLY
• The code to declare an element with attributes only:
<xs:element name="name">
<xs:complexType>
attributes
</xs:complexType>
</xs:element>
• Where attributes is the set of declarations that define the attributes associated with the
element. For example, the empty element:
<subject name="Cynthia Dibbs" age="62" />
• The code for this complex type element has the following structure:
<xs:element name="subject">
<xs:complexType>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="age" type="xs:string" />
</xs:complexType>
</xs:element>
SPECIFYING THE USE OFANATTRIBUTE
• An attribute may or may not be required with a particular element. To indicate whether an
attribute is required, you add the “use” attribute to the element declaration. The “use” attribute
has the following values:
• required: The attribute must always appear with the element
• optional: The use of the attribute is optional with the element
• prohibited: The attribute cannot be used with the element
• If you neglect to add the “use” attribute to an element declaration, the parser assumes that the
attribute is optional (meaning that “optional” is the default value for the “use” attribute).
• Example:
2-ELEMENTS WITH CHILD ELEMENTS ONLY
To define child elements, use the code structure:
<xs:element name="name">
<xs:complexType>
<xs:compositor>
elements
</xs:compositor>
</xs:complexType>
</xs:element>
Where elements is the list of simple type element declarations for each child element, and compositor defines
how the child elements are organized.
USING COMPOSITORS
XML Schema supports the following compositors:
• sequence: defines a specific order for the child elements
• choice: allows any one of the child elements to appear in the instance
document
• all: allows any of the child elements to appear in any order in the
instance document; however, they must appear at least once.
2-ELEMENTS WITH CHILD ELEMENTS ONLY(SEQUANCE EXAMPLE)
<element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
2-ELEMENTS WITH CHILD ELEMENTS ONLY
Example for choice compositor:
Example for all compositor:
COMBINING/NESTING COMPOSITORS
<xs:element name=“employee”>
<xs:complexType>
<xs:sequence>
<xs:element name=“name” type=“xs:string”/>
<xs:choice>
<xs:element name=“age” type=“xs:integer”/>
<xs:element name=“DOB” type=“xs:date”/>
</xs:choice>
<xs:all>
<xs:element name=“phone” type=“xs:string”/>
<xs:element name=“mobile” type=“xs:string”/>
<xs:element name=“email” type=“xs:string”/>
</xs:all>
</xs:sequence>
</xs:complexType>
</xs:element>
3- ELEMENTS WITH CHILD ELEMENTSANDATTRIBUTES
The code for a complex type element that contains both attributes and child elements is
<xs:element name="name">
<xs:complexType>
<xs:compositor>
Child Elements
</xs:compositor>
attributes
</xs:complexType>
</xs:element>
• The patient element contains two attributes (patID and onStudy) and seven child elements
(lastName, firstName, dateOfBirth, age, stage, comment, and performance.)
<xs:element name="patient">
<xs:complexType>
<xs:sequence>
<xs:element ref="lastName"/>
<xs:element ref="firstName"/>
<xs:element ref="dateOfBirth"/>
<xs:element ref="age"/>
<xs:element ref="stage"/>
<xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="performance"/>
</xs:sequence>
<xs:attribute ref="patID" use="required"/>
<xs:attribute ref="onStudy" use="required"/>
</xs:complexType>
</xs:element>
3- ELEMENTS WITH CHILD ELEMENTSANDATTRIBUTES
3- ELEMENTS WITH CHILD ELEMENTSANDATTRIBUTES
4- SPECIFYING MIXED CONTENT
• To declare an element that contains child elements and text, add the “mixed”
attribute and set it to “true”.
• Note that XML Schema allows content text to appear before, between, and after any
of the child elements.
For example, the XML content:
<Summary>
Patient <Name>Cynthia Davis</Name> was enrolled in
the <Study>Tamoxifen Study</Study> on 8/15/2003.
</Summary>
Can be declared in the schema file using the following complex type:
<xs:element name="Summary">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="Name" type=“xs:string"/>
<xs:element name="Study" type=“xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
4- SPECIFYING MIXED CONTENT
5- ELEMENTS WITH TEXTANDATTRIBUTES BUT NO CHILD ELEMENTS
If an element contains text and attributes (but no child elements), the structure of the
complex type element is slightly different.
<xs:element name="name">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:type">
attributes
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
For example, the empty element:
<performance scale="Karnofsky"> 0.81 </performance>
The code to associate the scale attribute with the performance element would
therefore be
<xs:element name="performance">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="scale"
type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
5- ELEMENTS WITH TEXTANDATTRIBUTES BUT NO CHILD
ELEMENTS
REFERENCINGAN ELEMENT ORATTRIBUTE
XML Schema allows for a great deal of flexibility in designing complex types. Rather
than nesting the attribute declaration within the element, you can create a reference to
it. The code to create a reference to an element or attribute declaration is
<xs:element ref="elemName" />
<xs:attribute ref="attName" />
Where elemName is the name used in an element declaration and attName is the name
used in an attribute declaration
EXAMPLE OFREFERENCINGAN ELEMENT ORATTRIBUTE
EXAMPLE OFREFERENCINGAN ELEMENT ORATTRIBUTE
SPECIFYING THE OCCURRENCE OFAN ITEM
• You can specify the occurrence of an element using the attributes minOccurs and maxOccurs.
• The minOccurs and maxOccurs can be any positive value
• The maxOccurs can have a value of “unbounded” for unlimited occurrences of the child
element
if minOccurs=”0” and maxOccurs is omitted ==> maxOccurs=”1” ==> the element is optional
if minOccurs=”x” and maxOccurs is omitted ==> maxOccurs=”x” (where x is any number greater
than 0)
if minOccurs and maxOccurs are both omitted ==> minOccurs=”1” and maxOccurs=”1”
*The default value for minOccurs and maxOccurs is “1”
“+” in DTDs is : minOccurs=“1” maxOccurs=“unbound”
“*” in DTDs is : minOccurs=“0” maxOccurs=“unbound”
“?” in DTDs is : minOccurs=“0” maxOccurs=“1”
SPECIFYING THE OCCURRENCE OFAN ITEM
SPECIFYING THE OCCURRENCE OFASEQUENCE
minOccurs and maxOccurs attributes can also be used with compositors to
repeat entire sequences of items
The Scope of an Element
Global Scope: Declarations that are placed as children of the root schema
element have a global scope, and can be referenced throughout the schema file.
Local Scope: Declarations that are nested within a complex type have a local
scope; they cannot be referenced elsewhere.
*Note:
• The attribute “use” for attributes is set locally.
• The attributes minOccurs and maxOccurs for elements are set locally.
• We declare the element or attribute globally, then specify the restrictions
locally.
XML SCHEMA DATA TYPES
• XML Schema supports two general categories of data types:
• A built-in data type is part of the XML Schema language and is
available to all XML Schema authors.
• A user-derived data type is created by a schema author for
specific data values in an instance document.
XML SCHEMA DATA TYPES
• XML Schema divides its built-in data types into two classes:
• A primitive data type, also called a base type, is one of 19 fundamental
data types not defined in terms of other types.
• A derived data type is a collection of 25 data types that the XML
Schema developers created based on the 19 primitive types.
• Unlike DTDs, schemas use the same data types for both elements and
attributes.
STRING DATA TYPES
STRING DATA TYPES
the string data types that we will use are: string , ID
NUMERIC DATA TYPES
NUMERIC DATA TYPES
DATES AND TIMES
DATES AND TIMES
the date and time data types we will use are: date , time
PATIENT.XSD USING THE “REF”
PATIENT.XSD WITHOUT USING THE “REF”
APPLYINGASCHEMATOAN XMLDOCUMENT
● To attach a schema to the document, you must do the following:
–Declare a namespace for XML Schema in the instance document.
–Indicate the location of the schema file.
● To declare the XML Schema namespace in the instance document, you add the
following attribute to the document’s root element:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
● If there is no namespace for the contents of the instance document, add the
following attribute to the root element:
xsi:noNamespaceSchemaLocation="schemaFile.xsd"
APPLYINGASCHEMATOAN XMLDOCUMENT
SUMMARY: SCHEMA ELEMENTS AND
ATTRIBUTES
Element Attribute
xs:schema xmlns:xs
xs:element name, type, minOccurs, maxOccurs, ref
xs:attribute name, type, use, default, fixed
xs:complexType mixed
xs:sequence minOccurs, maxOccurs
xs:choice minOccurs, maxOccurs
xs:all minOccurs, maxOccurs

More Related Content

What's hot

Xml schema
Xml schemaXml schema
Xml schema
Prabhakaran V M
 
Xml intro1
Xml intro1Xml intro1
XSLT
XSLTXSLT
Xsd examples
Xsd examplesXsd examples
Xsd examples
Bình Trọng Án
 
Xml schema
Xml schemaXml schema
Xml schema
sana mateen
 
Xml Schema
Xml SchemaXml Schema
Xml Schema
vikram singh
 
Xslt
XsltXslt
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
Amin Choroomi
 
XSD Incomplete Overview Draft
XSD Incomplete Overview DraftXSD Incomplete Overview Draft
XSD Incomplete Overview Draft
Pedro De Almeida
 
XSLT. Basic.
XSLT. Basic.XSLT. Basic.
XSLT. Basic.
Alexander Kirillov
 
Xslt tutorial
Xslt tutorialXslt tutorial
Xslt tutorial
Bijoy Kureekkal
 
Xslt
XsltXslt
Xml 2
Xml  2 Xml  2
Xsd tutorial
Xsd tutorialXsd tutorial
Xsd tutorial
Ashoka Vanjare
 
Advanced SQL Webinar
Advanced SQL WebinarAdvanced SQL Webinar
Advanced SQL Webinar
Ram Kedem
 
Chapter 18
Chapter 18Chapter 18
Introduction to SQL (for Chicago Booth MBA technology club)
Introduction to SQL (for Chicago Booth MBA technology club)Introduction to SQL (for Chicago Booth MBA technology club)
Introduction to SQL (for Chicago Booth MBA technology club)
Jennifer Berk
 
XML SCHEMAS
XML SCHEMASXML SCHEMAS
BIS05 Introduction to SQL
BIS05 Introduction to SQLBIS05 Introduction to SQL
BIS05 Introduction to SQL
Prithwis Mukerjee
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
Sabana Maharjan
 

What's hot (20)

Xml schema
Xml schemaXml schema
Xml schema
 
Xml intro1
Xml intro1Xml intro1
Xml intro1
 
XSLT
XSLTXSLT
XSLT
 
Xsd examples
Xsd examplesXsd examples
Xsd examples
 
Xml schema
Xml schemaXml schema
Xml schema
 
Xml Schema
Xml SchemaXml Schema
Xml Schema
 
Xslt
XsltXslt
Xslt
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
XSD Incomplete Overview Draft
XSD Incomplete Overview DraftXSD Incomplete Overview Draft
XSD Incomplete Overview Draft
 
XSLT. Basic.
XSLT. Basic.XSLT. Basic.
XSLT. Basic.
 
Xslt tutorial
Xslt tutorialXslt tutorial
Xslt tutorial
 
Xslt
XsltXslt
Xslt
 
Xml 2
Xml  2 Xml  2
Xml 2
 
Xsd tutorial
Xsd tutorialXsd tutorial
Xsd tutorial
 
Advanced SQL Webinar
Advanced SQL WebinarAdvanced SQL Webinar
Advanced SQL Webinar
 
Chapter 18
Chapter 18Chapter 18
Chapter 18
 
Introduction to SQL (for Chicago Booth MBA technology club)
Introduction to SQL (for Chicago Booth MBA technology club)Introduction to SQL (for Chicago Booth MBA technology club)
Introduction to SQL (for Chicago Booth MBA technology club)
 
XML SCHEMAS
XML SCHEMASXML SCHEMAS
XML SCHEMAS
 
BIS05 Introduction to SQL
BIS05 Introduction to SQLBIS05 Introduction to SQL
BIS05 Introduction to SQL
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 

Viewers also liked

Xml part 6
Xml part 6Xml part 6
Xml part 6
NOHA AW
 
Web Services
Web ServicesWeb Services
Web Services
Gaurav Tyagi
 
The Mystical Principles of XSLT: Enlightenment through Software Visualization
The Mystical Principles of XSLT: Enlightenment through Software VisualizationThe Mystical Principles of XSLT: Enlightenment through Software Visualization
The Mystical Principles of XSLT: Enlightenment through Software Visualization
evanlenz
 
Unleashing the Power of XSLT: Catalog Records in Batch
Unleashing the Power of XSLT: Catalog Records in BatchUnleashing the Power of XSLT: Catalog Records in Batch
Unleashing the Power of XSLT: Catalog Records in Batch
c7002593
 
Applying an IBM SOA Approach to Manual Processes Automation
Applying an IBM SOA Approach to Manual Processes AutomationApplying an IBM SOA Approach to Manual Processes Automation
Applying an IBM SOA Approach to Manual Processes Automation
Prolifics
 
XML - Displaying Data ith XSLT
XML - Displaying Data ith XSLTXML - Displaying Data ith XSLT
XML - Displaying Data ith XSLT
Dudy Ali
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WS
Carol McDonald
 
SOA Governance and WebSphere Service Registry and Repository
SOA Governance and WebSphere Service Registry and RepositorySOA Governance and WebSphere Service Registry and Repository
SOA Governance and WebSphere Service Registry and Repository
IBM Sverige
 
Open Id, O Auth And Webservices
Open Id, O Auth And WebservicesOpen Id, O Auth And Webservices
Open Id, O Auth And Webservices
Myles Eftos
 
XSLT for Web Developers
XSLT for Web DevelopersXSLT for Web Developers
XSLT for Web Developers
Sanders Kleinfeld
 
Web Services
Web ServicesWeb Services
Web Services
Gaurav Tyagi
 
Web services
Web servicesWeb services
Web services
Michael Weiss
 
WebService-Java
WebService-JavaWebService-Java
WebService-Java
halwal
 
Siebel Web Service
Siebel Web ServiceSiebel Web Service
Siebel Web Service
NAVINKUMAR RAI
 
CTDA Workshop on XSL
CTDA Workshop on XSLCTDA Workshop on XSL
RESTful services
RESTful servicesRESTful services
RESTful services
gouthamrv
 
Java web services using JAX-WS
Java web services using JAX-WSJava web services using JAX-WS
Java web services using JAX-WS
IndicThreads
 
XSLT
XSLTXSLT
XSLT
rpoplai
 
OAuth 2.0 with IBM WebSphere DataPower
OAuth 2.0 with IBM WebSphere DataPowerOAuth 2.0 with IBM WebSphere DataPower
OAuth 2.0 with IBM WebSphere DataPower
Shiu-Fun Poon
 
SOAP-based Web Services
SOAP-based Web ServicesSOAP-based Web Services
SOAP-based Web Services
Katrien Verbert
 

Viewers also liked (20)

Xml part 6
Xml part 6Xml part 6
Xml part 6
 
Web Services
Web ServicesWeb Services
Web Services
 
The Mystical Principles of XSLT: Enlightenment through Software Visualization
The Mystical Principles of XSLT: Enlightenment through Software VisualizationThe Mystical Principles of XSLT: Enlightenment through Software Visualization
The Mystical Principles of XSLT: Enlightenment through Software Visualization
 
Unleashing the Power of XSLT: Catalog Records in Batch
Unleashing the Power of XSLT: Catalog Records in BatchUnleashing the Power of XSLT: Catalog Records in Batch
Unleashing the Power of XSLT: Catalog Records in Batch
 
Applying an IBM SOA Approach to Manual Processes Automation
Applying an IBM SOA Approach to Manual Processes AutomationApplying an IBM SOA Approach to Manual Processes Automation
Applying an IBM SOA Approach to Manual Processes Automation
 
XML - Displaying Data ith XSLT
XML - Displaying Data ith XSLTXML - Displaying Data ith XSLT
XML - Displaying Data ith XSLT
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WS
 
SOA Governance and WebSphere Service Registry and Repository
SOA Governance and WebSphere Service Registry and RepositorySOA Governance and WebSphere Service Registry and Repository
SOA Governance and WebSphere Service Registry and Repository
 
Open Id, O Auth And Webservices
Open Id, O Auth And WebservicesOpen Id, O Auth And Webservices
Open Id, O Auth And Webservices
 
XSLT for Web Developers
XSLT for Web DevelopersXSLT for Web Developers
XSLT for Web Developers
 
Web Services
Web ServicesWeb Services
Web Services
 
Web services
Web servicesWeb services
Web services
 
WebService-Java
WebService-JavaWebService-Java
WebService-Java
 
Siebel Web Service
Siebel Web ServiceSiebel Web Service
Siebel Web Service
 
CTDA Workshop on XSL
CTDA Workshop on XSLCTDA Workshop on XSL
CTDA Workshop on XSL
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
Java web services using JAX-WS
Java web services using JAX-WSJava web services using JAX-WS
Java web services using JAX-WS
 
XSLT
XSLTXSLT
XSLT
 
OAuth 2.0 with IBM WebSphere DataPower
OAuth 2.0 with IBM WebSphere DataPowerOAuth 2.0 with IBM WebSphere DataPower
OAuth 2.0 with IBM WebSphere DataPower
 
SOAP-based Web Services
SOAP-based Web ServicesSOAP-based Web Services
SOAP-based Web Services
 

Similar to Xml part4

02 xml schema
02 xml schema02 xml schema
02 xml schema
Baskarkncet
 
Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
XML Schema
XML SchemaXML Schema
XML Schema
yht4ever
 
Web Service Workshop - 3 days
Web Service Workshop - 3 daysWeb Service Workshop - 3 days
Web Service Workshop - 3 days
David Ionut
 
Xml For Dummies Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
Xml For Dummies   Chapter 10 Building A Custom Xml Schema it-slideshares.blog...Xml For Dummies   Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
Xml For Dummies Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
phanleson
 
Xsd
XsdXsd
Xsd
XsdXsd
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_schema_Structure
XML_schema_StructureXML_schema_Structure
XML_schema_Structure
Vijay Kumar Verma
 
XML
XMLXML
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
Pradeep Rapolu
 
XML-Schema-Elements_Types_Attributes.pptx
XML-Schema-Elements_Types_Attributes.pptxXML-Schema-Elements_Types_Attributes.pptx
XML-Schema-Elements_Types_Attributes.pptx
AkshayKumar100378
 
XML Fundamentals
XML FundamentalsXML Fundamentals
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
Swati Parmar
 
Day2 xslt x_path_xquery
Day2 xslt x_path_xqueryDay2 xslt x_path_xquery
Day2 xslt x_path_xquery
XAVIERCONSULTANTS
 
Tool Development 05 - XML Schema, INI, JSON, YAML
Tool Development 05 - XML Schema, INI, JSON, YAMLTool Development 05 - XML Schema, INI, JSON, YAML
Tool Development 05 - XML Schema, INI, JSON, YAML
Nick Pruehs
 
Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)
Sumant Tambe
 
Service Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIService Oriented Architecture - Unit II
Service Oriented Architecture - Unit II
Roselin Mary S
 
Xml session
Xml sessionXml session
Xml session
Farag Zakaria
 
Week 12 xml and xsl
Week 12 xml and xslWeek 12 xml and xsl
Week 12 xml and xsl
hapy
 

Similar to Xml part4 (20)

02 xml schema
02 xml schema02 xml schema
02 xml schema
 
Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
Schemas 2 - Restricting Values
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Web Service Workshop - 3 days
Web Service Workshop - 3 daysWeb Service Workshop - 3 days
Web Service Workshop - 3 days
 
Xml For Dummies Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
Xml For Dummies   Chapter 10 Building A Custom Xml Schema it-slideshares.blog...Xml For Dummies   Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
Xml For Dummies Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
 
Xsd
XsdXsd
Xsd
 
Xsd
XsdXsd
Xsd
 
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_schema_Structure
XML_schema_StructureXML_schema_Structure
XML_schema_Structure
 
XML
XMLXML
XML
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
XML-Schema-Elements_Types_Attributes.pptx
XML-Schema-Elements_Types_Attributes.pptxXML-Schema-Elements_Types_Attributes.pptx
XML-Schema-Elements_Types_Attributes.pptx
 
XML Fundamentals
XML FundamentalsXML Fundamentals
XML Fundamentals
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
Day2 xslt x_path_xquery
Day2 xslt x_path_xqueryDay2 xslt x_path_xquery
Day2 xslt x_path_xquery
 
Tool Development 05 - XML Schema, INI, JSON, YAML
Tool Development 05 - XML Schema, INI, JSON, YAMLTool Development 05 - XML Schema, INI, JSON, YAML
Tool Development 05 - XML Schema, INI, JSON, YAML
 
Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)
 
Service Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIService Oriented Architecture - Unit II
Service Oriented Architecture - Unit II
 
Xml session
Xml sessionXml session
Xml session
 
Week 12 xml and xsl
Week 12 xml and xslWeek 12 xml and xsl
Week 12 xml and xsl
 

Recently uploaded

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 

Xml part4

  • 2. LIMITATION OF DTD • DTD has limitation on the number of data type can be used. • Can not recognize the namespace.
  • 3. SCHEMAS ● A schema is an XML document that defines the content and structure of one or more XML documents. ● The XML document that will be validated is called the instance document. ● Why Use an XML Schema? ● With XML Schema, your XML files can carry a description of its own format.
  • 5. XML SCHEMA V.S DTD • XML Schemas are More Powerful than DTD: • XML Schemas are written in XML. • XML Schema supports a collection of built-in data types and allows programmers to define their own data types. • XML Schemas support data types. • XML Schemas support namespaces.
  • 6. STARTING A SCHEMA FILE • A schema is always placed in a separate XML document that is referenced by the instance document. • A file written in XML Schema has the extension .xsd • Since the Schema file is actually an XML file, it must start with an XML declaration. • The root element in any XML Schema document is the schema element , and it must declare a namespace for the XML Schema. <?xml version=“1.0” encoding=“UTF=8”?> <xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”> schema content </xs:schema>
  • 8.
  • 9. SCHEMATYPES XML Schema recognize two categories of element types that are: 1. A complex type element has one or more attributes, or is the parent to one or more child elements. 2. A simple type element contains only character data and has no attributes.
  • 13. SIMPLE TYPE ELEMENTS • Use the following syntax to declare a simple type element in XML Schema: <xs:element name=“name” type =“xs:type”/> ● Here, name is the name of the element in the instance document and type is the datatype of the element. ● XML Schema tags must be qualified with the namespace prefix.
  • 14.
  • 15. DECLARINGANATTRIBUTE • An attribute is always a simple type. The syntax to define an attribute is <xs:attribute name="name" type="xs:type” /> • Where name is the name of the attribute and type is the data type. • You can also define a default value and a fixed value for the attribute: <xs:attribute name="name" type="xs:type” default=“default value” fixed=“fixed value" /> • The default and fixed attributes are optional.
  • 16. * notice that we did not specify which element the attribute belongs to
  • 18. COMPLEX TYPE ELEMENTS The basic structure for defining a complex type element with XML Schema is <xs:element name="name"> <xs:complexType> declarations </xs:complexType> </xs:element> Where name is the name of the element and declarations are the declarations of the child elements or attributes associated with the element.
  • 19. COMPLEX TYPE ELEMENTS Five complex type elements that usually appear in an instance document are the following: 1–The element is an empty element and contains attributes only. 2–The element contains child elements only. 3–The element contains both child elements and attributes. 4–The element contains both child elements and text. 5–The element contains both attributes and text but no child element.
  • 20. 1- ELEMENTS WITHATTRIBUTES ONLY • The code to declare an element with attributes only: <xs:element name="name"> <xs:complexType> attributes </xs:complexType> </xs:element> • Where attributes is the set of declarations that define the attributes associated with the element. For example, the empty element: <subject name="Cynthia Dibbs" age="62" /> • The code for this complex type element has the following structure: <xs:element name="subject"> <xs:complexType> <xs:attribute name="name" type="xs:string" /> <xs:attribute name="age" type="xs:string" /> </xs:complexType> </xs:element>
  • 21. SPECIFYING THE USE OFANATTRIBUTE • An attribute may or may not be required with a particular element. To indicate whether an attribute is required, you add the “use” attribute to the element declaration. The “use” attribute has the following values: • required: The attribute must always appear with the element • optional: The use of the attribute is optional with the element • prohibited: The attribute cannot be used with the element • If you neglect to add the “use” attribute to an element declaration, the parser assumes that the attribute is optional (meaning that “optional” is the default value for the “use” attribute). • Example:
  • 22. 2-ELEMENTS WITH CHILD ELEMENTS ONLY To define child elements, use the code structure: <xs:element name="name"> <xs:complexType> <xs:compositor> elements </xs:compositor> </xs:complexType> </xs:element> Where elements is the list of simple type element declarations for each child element, and compositor defines how the child elements are organized.
  • 23. USING COMPOSITORS XML Schema supports the following compositors: • sequence: defines a specific order for the child elements • choice: allows any one of the child elements to appear in the instance document • all: allows any of the child elements to appear in any order in the instance document; however, they must appear at least once.
  • 24. 2-ELEMENTS WITH CHILD ELEMENTS ONLY(SEQUANCE EXAMPLE) <element name="address"> <xs:complexType> <xs:sequence> <xs:element name="street" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="state" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
  • 25. 2-ELEMENTS WITH CHILD ELEMENTS ONLY Example for choice compositor: Example for all compositor:
  • 26. COMBINING/NESTING COMPOSITORS <xs:element name=“employee”> <xs:complexType> <xs:sequence> <xs:element name=“name” type=“xs:string”/> <xs:choice> <xs:element name=“age” type=“xs:integer”/> <xs:element name=“DOB” type=“xs:date”/> </xs:choice> <xs:all> <xs:element name=“phone” type=“xs:string”/> <xs:element name=“mobile” type=“xs:string”/> <xs:element name=“email” type=“xs:string”/> </xs:all> </xs:sequence> </xs:complexType> </xs:element>
  • 27. 3- ELEMENTS WITH CHILD ELEMENTSANDATTRIBUTES The code for a complex type element that contains both attributes and child elements is <xs:element name="name"> <xs:complexType> <xs:compositor> Child Elements </xs:compositor> attributes </xs:complexType> </xs:element>
  • 28. • The patient element contains two attributes (patID and onStudy) and seven child elements (lastName, firstName, dateOfBirth, age, stage, comment, and performance.) <xs:element name="patient"> <xs:complexType> <xs:sequence> <xs:element ref="lastName"/> <xs:element ref="firstName"/> <xs:element ref="dateOfBirth"/> <xs:element ref="age"/> <xs:element ref="stage"/> <xs:element ref="comment" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="performance"/> </xs:sequence> <xs:attribute ref="patID" use="required"/> <xs:attribute ref="onStudy" use="required"/> </xs:complexType> </xs:element> 3- ELEMENTS WITH CHILD ELEMENTSANDATTRIBUTES
  • 29. 3- ELEMENTS WITH CHILD ELEMENTSANDATTRIBUTES
  • 30. 4- SPECIFYING MIXED CONTENT • To declare an element that contains child elements and text, add the “mixed” attribute and set it to “true”. • Note that XML Schema allows content text to appear before, between, and after any of the child elements.
  • 31. For example, the XML content: <Summary> Patient <Name>Cynthia Davis</Name> was enrolled in the <Study>Tamoxifen Study</Study> on 8/15/2003. </Summary> Can be declared in the schema file using the following complex type: <xs:element name="Summary"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="Name" type=“xs:string"/> <xs:element name="Study" type=“xs:string"/> </xs:sequence> </xs:complexType> </xs:element> 4- SPECIFYING MIXED CONTENT
  • 32. 5- ELEMENTS WITH TEXTANDATTRIBUTES BUT NO CHILD ELEMENTS If an element contains text and attributes (but no child elements), the structure of the complex type element is slightly different. <xs:element name="name"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:type"> attributes </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element>
  • 33. For example, the empty element: <performance scale="Karnofsky"> 0.81 </performance> The code to associate the scale attribute with the performance element would therefore be <xs:element name="performance"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="scale" type="xs:string" /> </xs:extension> </xs:simpleContent> </xs:complexType> 5- ELEMENTS WITH TEXTANDATTRIBUTES BUT NO CHILD ELEMENTS
  • 34. REFERENCINGAN ELEMENT ORATTRIBUTE XML Schema allows for a great deal of flexibility in designing complex types. Rather than nesting the attribute declaration within the element, you can create a reference to it. The code to create a reference to an element or attribute declaration is <xs:element ref="elemName" /> <xs:attribute ref="attName" /> Where elemName is the name used in an element declaration and attName is the name used in an attribute declaration
  • 37. SPECIFYING THE OCCURRENCE OFAN ITEM • You can specify the occurrence of an element using the attributes minOccurs and maxOccurs. • The minOccurs and maxOccurs can be any positive value • The maxOccurs can have a value of “unbounded” for unlimited occurrences of the child element if minOccurs=”0” and maxOccurs is omitted ==> maxOccurs=”1” ==> the element is optional if minOccurs=”x” and maxOccurs is omitted ==> maxOccurs=”x” (where x is any number greater than 0) if minOccurs and maxOccurs are both omitted ==> minOccurs=”1” and maxOccurs=”1” *The default value for minOccurs and maxOccurs is “1” “+” in DTDs is : minOccurs=“1” maxOccurs=“unbound” “*” in DTDs is : minOccurs=“0” maxOccurs=“unbound” “?” in DTDs is : minOccurs=“0” maxOccurs=“1”
  • 39. SPECIFYING THE OCCURRENCE OFASEQUENCE minOccurs and maxOccurs attributes can also be used with compositors to repeat entire sequences of items
  • 40. The Scope of an Element Global Scope: Declarations that are placed as children of the root schema element have a global scope, and can be referenced throughout the schema file. Local Scope: Declarations that are nested within a complex type have a local scope; they cannot be referenced elsewhere. *Note: • The attribute “use” for attributes is set locally. • The attributes minOccurs and maxOccurs for elements are set locally. • We declare the element or attribute globally, then specify the restrictions locally.
  • 41.
  • 42. XML SCHEMA DATA TYPES • XML Schema supports two general categories of data types: • A built-in data type is part of the XML Schema language and is available to all XML Schema authors. • A user-derived data type is created by a schema author for specific data values in an instance document.
  • 43. XML SCHEMA DATA TYPES • XML Schema divides its built-in data types into two classes: • A primitive data type, also called a base type, is one of 19 fundamental data types not defined in terms of other types. • A derived data type is a collection of 25 data types that the XML Schema developers created based on the 19 primitive types. • Unlike DTDs, schemas use the same data types for both elements and attributes.
  • 44.
  • 46. STRING DATA TYPES the string data types that we will use are: string , ID
  • 50. DATES AND TIMES the date and time data types we will use are: date , time
  • 52. PATIENT.XSD WITHOUT USING THE “REF”
  • 53. APPLYINGASCHEMATOAN XMLDOCUMENT ● To attach a schema to the document, you must do the following: –Declare a namespace for XML Schema in the instance document. –Indicate the location of the schema file. ● To declare the XML Schema namespace in the instance document, you add the following attribute to the document’s root element: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ● If there is no namespace for the contents of the instance document, add the following attribute to the root element: xsi:noNamespaceSchemaLocation="schemaFile.xsd"
  • 55. SUMMARY: SCHEMA ELEMENTS AND ATTRIBUTES Element Attribute xs:schema xmlns:xs xs:element name, type, minOccurs, maxOccurs, ref xs:attribute name, type, use, default, fixed xs:complexType mixed xs:sequence minOccurs, maxOccurs xs:choice minOccurs, maxOccurs xs:all minOccurs, maxOccurs