SlideShare a Scribd company logo
XML SchemasCIS-189
Alternative to DTD’s as way to define structureDefining a language (vocabulary)Structure may be also referred to as vocabularyEnsures that data matches specificationsServes as basis for other XML-related technologiesXML Schemas
Use XML for definitionDoesn’t have separate structure like DTD’sSchema must be well-formedProvides for built-in and user-defined data typesCan be easily reusedSupports concepts such as inheritanceOne object is based on anotherA definition may be reused and modified without starting from scratch each timeWorking with Schemas
Support World Wide Web Namespace recommendationsA namespace allows the same name (data type/definition) to be used in different Schemas and properly understoodA course may be defined as department, course number, title, credits and prerequisites for the College CatalogA course for grading may be defined as department, course number and credits for a grading applicationUsing namespaces allows both definitions to be used, by specifying if working with a course defined for the catalog or gradingSchemas and Namespaces
Schema file uses an .xsd extensionRoot element is the schemaCan nest all elements within the schemaEverything is hierarchicalORCan have multiple elements as child elements of the schema rootAllows use of a definition any place in the document (data) fileElements which are child elements of schema are globalCreating Schemas
Allows more specificity than DTD’sCan specify dates, numbers, rangesDatatypes fall into two categories:Simple deals with basic valuesComplex describes more intricate values or structuresSchema Datatypes
Simple data type is about text, numbers, dateSometime referred to as “primitives”Data types built in to Schema vocabulary (and related elements, attributes) are in the XML Schema namespaceNeed reference to namespace to have valid XML specified (where to find the defined type)Elements that are Simple Datatypes don’t have attributesIncluding an attribute makes an element ComplexSimple Datatypes
StringBooleanNumbersIntegerDecimalFloatDoubleCustom (simpleType)Date/timeTimeTimeInstantDurationDateMonthYearCenturyRecurringDateRecurringDaySimple Types
<?xml version=“1.0”?><xsd:schemaxmlns:xsd=“http://www.w3.org/2001/XMLSchema”>	<xsd:element name=“department” type=“xsd:string”/>	<xsd:element name=“number” type=“xsd:string”/>	<xsd:element name=“title” type=“xsd:string”/>	<xsd:element name=“credits” type=“xsd:integer”/></schema>Schema Defining a Course Using Simple Typesxmlns:xsd= specifies where the namespace can be foundxsd: specifies the namespace where the definition existsAssign attribute values to create the definition of an element in your vocabulary
The simpleType allows customization of base typesCan create limits on valuesSpecify rangesSpecify listsDegrees is a simple type, based on string:<xsd:simpleType=“Degrees”>	<xsd:restriction base=“xsd:string”>		<xsd:enumeration value=“AA” />		<xsd:enumeration value=“AS” />	</xsd: restriction></xsd:simpleType>Defining (Simple) Datatypes
Complex types allows combination of different elements and specification of order, new data typesCan create an element Course which is comprised of simple typesA valid Course must have department, number, title and credits elements in order:<xsd:element name=“course”>	<xsd:complexType>		<xsd:sequence>		<xsd:element name=“department” type=“xsd:string”/>		<xsd:element name=“number” type=“xsd:string”/>		<xsd:element name=“title” type=“xsd:string”/>		<xsd:element name=“credits” type=“xsd:integer”/>		</xsd:sequence>	</xsd:complexType></xsd:element>ComplexDatatypes
When using a schema, need to create a reference from data (.xml) fileUse either the schemaLocation or noNamespaceSchemaLocation attribute of the root element<course xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceShemaLocation=“course.xsd”>Using a Schema
Creating a simple typeA phone number is text, up to 20 characters<xs:simpleType name="PhoneSimpleType“>	<xs:restrictionbase="xs:string“>		<xs:maxLength value="20" />	</xs:restriction></xs:simpleType>Book Code – Employees.xsd
Using a simple type:The element homephone uses the simple type “PhoneSimpleType” to limit phone numbers to a maximum of 20 characters<xs:element name="homephone" type="PhoneSimpleType" />Book Code – Employees.xsd 2
Employees is a complex type made of employee, which uses the EmployeeType<xs:element name="employees“>	<xs:complexType>	<xs:sequence>		<xs:element name="employee" type="EmployeeType" minOccurs="0" maxOccurs="unbounded" />	</xs:sequence></xs:complexType></xs:element>Book Code – Employees.xsd 3
Setting the root element for a schema<?xml version="1.0" encoding="utf-8"?><xs:schemaattributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">Book Code – Employees.xsd 4xs becomes “shorthand” to refer to the Internet location for definitions; following element definitions all include that reference (xs)

More Related Content

PPTX
Publishing xml
PPT
Xml Schema
PPTX
XML Schema
PPT
Xsd examples
PPTX
XML Schemas
PPTX
XML's validation - XML Schema
PPT
02 xml schema
PPT
Xml schema
Publishing xml
Xml Schema
XML Schema
Xsd examples
XML Schemas
XML's validation - XML Schema
02 xml schema
Xml schema

What's hot (15)

PDF
Xml schema
DOCX
Introduction to xml schema
PPTX
Xml schema
PPTX
Xml schema
PPTX
Extracting data from xml
PPT
PPTX
XML DTD and Schema
PPT
Xml and webdata
PPT
XML Schema
PPTX
DTD
PPT
Xml and Co.
PPTX
Introduction to XML
PPT
01 xml document structure
PPTX
Xml presentation
PPTX
XML, DTD & XSD Overview
Xml schema
Introduction to xml schema
Xml schema
Xml schema
Extracting data from xml
XML DTD and Schema
Xml and webdata
XML Schema
DTD
Xml and Co.
Introduction to XML
01 xml document structure
Xml presentation
XML, DTD & XSD Overview
Ad

Similar to XML schemas (20)

PPTX
XML Schema.pptx
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPTX
Unit-III_JQuery.pptx engineering subject for third year students
PPTX
advDBMS_XML.pptx
PPTX
XPATH_XSLT-1.pptx
PPTX
distributed system concerned lab sessions
PPT
DATA INTEGRATION (Gaining Access to Diverse Data).ppt
PPT
XML stands for EXtensible Markup Language
PPT
XMLLec1.pptsfsfsafasfasdfasfdsadfdsfdf dfdsfds
PPT
XMLLec1 (1xML lecturefsfsdfsdfdsfdsfsdfsdfdsf
PPT
O9schema
PPT
Schema
PDF
Advanced Web Programming Chapter 12
PPTX
XSD Schema Presentation on basic of the schema 2
PPTX
XML_schema_Structure
XML Schema.pptx
Xml and webdata
Xml and webdata
Xml and webdata
Xml and webdata
Xml and webdata
Xml and webdata
Unit-III_JQuery.pptx engineering subject for third year students
advDBMS_XML.pptx
XPATH_XSLT-1.pptx
distributed system concerned lab sessions
DATA INTEGRATION (Gaining Access to Diverse Data).ppt
XML stands for EXtensible Markup Language
XMLLec1.pptsfsfsafasfasdfasfdsadfdsfdf dfdsfds
XMLLec1 (1xML lecturefsfsdfsdfdsfdsfsdfsdfdsf
O9schema
Schema
Advanced Web Programming Chapter 12
XSD Schema Presentation on basic of the schema 2
XML_schema_Structure
Ad

More from Randy Riness @ South Puget Sound Community College (20)

Recently uploaded (20)

PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Classroom Observation Tools for Teachers
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Lesson notes of climatology university.
PPTX
Cell Structure & Organelles in detailed.
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Computing-Curriculum for Schools in Ghana
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
O7-L3 Supply Chain Operations - ICLT Program
VCE English Exam - Section C Student Revision Booklet
Microbial disease of the cardiovascular and lymphatic systems
Classroom Observation Tools for Teachers
PPH.pptx obstetrics and gynecology in nursing
Sports Quiz easy sports quiz sports quiz
Lesson notes of climatology university.
Cell Structure & Organelles in detailed.
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
O5-L3 Freight Transport Ops (International) V1.pdf
Final Presentation General Medicine 03-08-2024.pptx
RMMM.pdf make it easy to upload and study
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Institutional Correction lecture only . . .
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Computing-Curriculum for Schools in Ghana
Abdominal Access Techniques with Prof. Dr. R K Mishra
3rd Neelam Sanjeevareddy Memorial Lecture.pdf

XML schemas

  • 2. Alternative to DTD’s as way to define structureDefining a language (vocabulary)Structure may be also referred to as vocabularyEnsures that data matches specificationsServes as basis for other XML-related technologiesXML Schemas
  • 3. Use XML for definitionDoesn’t have separate structure like DTD’sSchema must be well-formedProvides for built-in and user-defined data typesCan be easily reusedSupports concepts such as inheritanceOne object is based on anotherA definition may be reused and modified without starting from scratch each timeWorking with Schemas
  • 4. Support World Wide Web Namespace recommendationsA namespace allows the same name (data type/definition) to be used in different Schemas and properly understoodA course may be defined as department, course number, title, credits and prerequisites for the College CatalogA course for grading may be defined as department, course number and credits for a grading applicationUsing namespaces allows both definitions to be used, by specifying if working with a course defined for the catalog or gradingSchemas and Namespaces
  • 5. Schema file uses an .xsd extensionRoot element is the schemaCan nest all elements within the schemaEverything is hierarchicalORCan have multiple elements as child elements of the schema rootAllows use of a definition any place in the document (data) fileElements which are child elements of schema are globalCreating Schemas
  • 6. Allows more specificity than DTD’sCan specify dates, numbers, rangesDatatypes fall into two categories:Simple deals with basic valuesComplex describes more intricate values or structuresSchema Datatypes
  • 7. Simple data type is about text, numbers, dateSometime referred to as “primitives”Data types built in to Schema vocabulary (and related elements, attributes) are in the XML Schema namespaceNeed reference to namespace to have valid XML specified (where to find the defined type)Elements that are Simple Datatypes don’t have attributesIncluding an attribute makes an element ComplexSimple Datatypes
  • 9. <?xml version=“1.0”?><xsd:schemaxmlns:xsd=“http://www.w3.org/2001/XMLSchema”> <xsd:element name=“department” type=“xsd:string”/> <xsd:element name=“number” type=“xsd:string”/> <xsd:element name=“title” type=“xsd:string”/> <xsd:element name=“credits” type=“xsd:integer”/></schema>Schema Defining a Course Using Simple Typesxmlns:xsd= specifies where the namespace can be foundxsd: specifies the namespace where the definition existsAssign attribute values to create the definition of an element in your vocabulary
  • 10. The simpleType allows customization of base typesCan create limits on valuesSpecify rangesSpecify listsDegrees is a simple type, based on string:<xsd:simpleType=“Degrees”> <xsd:restriction base=“xsd:string”> <xsd:enumeration value=“AA” /> <xsd:enumeration value=“AS” /> </xsd: restriction></xsd:simpleType>Defining (Simple) Datatypes
  • 11. Complex types allows combination of different elements and specification of order, new data typesCan create an element Course which is comprised of simple typesA valid Course must have department, number, title and credits elements in order:<xsd:element name=“course”> <xsd:complexType> <xsd:sequence> <xsd:element name=“department” type=“xsd:string”/> <xsd:element name=“number” type=“xsd:string”/> <xsd:element name=“title” type=“xsd:string”/> <xsd:element name=“credits” type=“xsd:integer”/> </xsd:sequence> </xsd:complexType></xsd:element>ComplexDatatypes
  • 12. When using a schema, need to create a reference from data (.xml) fileUse either the schemaLocation or noNamespaceSchemaLocation attribute of the root element<course xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceShemaLocation=“course.xsd”>Using a Schema
  • 13. Creating a simple typeA phone number is text, up to 20 characters<xs:simpleType name="PhoneSimpleType“> <xs:restrictionbase="xs:string“> <xs:maxLength value="20" /> </xs:restriction></xs:simpleType>Book Code – Employees.xsd
  • 14. Using a simple type:The element homephone uses the simple type “PhoneSimpleType” to limit phone numbers to a maximum of 20 characters<xs:element name="homephone" type="PhoneSimpleType" />Book Code – Employees.xsd 2
  • 15. Employees is a complex type made of employee, which uses the EmployeeType<xs:element name="employees“> <xs:complexType> <xs:sequence> <xs:element name="employee" type="EmployeeType" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence></xs:complexType></xs:element>Book Code – Employees.xsd 3
  • 16. Setting the root element for a schema<?xml version="1.0" encoding="utf-8"?><xs:schemaattributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">Book Code – Employees.xsd 4xs becomes “shorthand” to refer to the Internet location for definitions; following element definitions all include that reference (xs)