Download presentation
Presentation is loading. Please wait.
Published byJared Gregory Modified over 9 years ago
1
XML Schema Definition (XSD)
2
Definition of a Schema It is a model for describing the structure and content of data The XML Schema was developed as a content modeling language, based on XML Not based on SGML It is a model for describing the structure and content of data The XML Schema was developed as a content modeling language, based on XML Not based on SGML
3
Definition of a Schema (cont’d) The XML Schema (XSD) pertains only to XML and XML-related languages (e.g. WSDL) Based upon the specification found at http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema The XML Schema (XSD) pertains only to XML and XML-related languages (e.g. WSDL) Based upon the specification found at http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema
4
An XSD: Is a model for a whole class of documents Describes the possible arrangement of elements, attributes, and text in a schema-valid document Models are described in terms of constraints Provides the ability to validate a document at machine speed Instance documents: XML documents that conform to a specific schema Is a model for a whole class of documents Describes the possible arrangement of elements, attributes, and text in a schema-valid document Models are described in terms of constraints Provides the ability to validate a document at machine speed Instance documents: XML documents that conform to a specific schema
5
XSD Constraints A constraint defines what can appear in a given language or document Content model constraints: –Define the elements that can appear –Establishes a vocabulary for a class of documents A constraint defines what can appear in a given language or document Content model constraints: –Define the elements that can appear –Establishes a vocabulary for a class of documents
6
XSD Constraints (cont’d) Datatype constraints: –Describe the units of data that the schema considers valid Datatype constraints: –Describe the units of data that the schema considers valid
7
Schema Components Prolog Schema element Elements SubElements Attributes and cardinality Facets Prolog Schema element Elements SubElements Attributes and cardinality Facets
8
The Schema Prolog Consists of the declaration and zero or more comment lines Declaration: – Comment:: –<!– edited with Visual Studio.NET by Prof. Hull – --> Consists of the declaration and zero or more comment lines Declaration: – Comment:: –<!– edited with Visual Studio.NET by Prof. Hull – -->
9
The “Schema” Element Usually represented as The schema definition ends with Is equivalent to the root element of an XML document Therefore, it is the parent element of all other elements in the schema These other elements, or sub-elements, are referred to as child elements in XML documents Usually represented as The schema definition ends with Is equivalent to the root element of an XML document Therefore, it is the parent element of all other elements in the schema These other elements, or sub-elements, are referred to as child elements in XML documents
10
The “Schema” Element (cont’d) Includes two attributes: –Namespace attribute –Qualified or unqualified local elements Includes two attributes: –Namespace attribute –Qualified or unqualified local elements
11
The Namespace Attribute The bolded portion is the namespace declaration This assignment indicates to the XML processor that definitions and treatments of elements and other datatypes in the schema are adopted from the W3C’s Namespace Recommendation The xmlns attribute specifies the alias to be used throughout the schema to reference the Recommendation When the XML processor encounters the alias name “xsd”, it uses the definitions in the Recommendation The bolded portion is the namespace declaration This assignment indicates to the XML processor that definitions and treatments of elements and other datatypes in the schema are adopted from the W3C’s Namespace Recommendation The xmlns attribute specifies the alias to be used throughout the schema to reference the Recommendation When the XML processor encounters the alias name “xsd”, it uses the definitions in the Recommendation
12
The Namespace Attribute (cont’d) Each namespace represents a collection of element types and other data types It is represented by a unique name That unique name takes the form of a URL The URL is used only as a name, not as a location on the Internet (browsers are not invoked) Each namespace represents a collection of element types and other data types It is represented by a unique name That unique name takes the form of a URL The URL is used only as a name, not as a location on the Internet (browsers are not invoked)
13
Hybrid Names in Namespaces xsd:annotation xsd:attribute xsd:attributeGroup xsd:complexType xsd:element xsd:annotation xsd:attribute xsd:attributeGroup xsd:complexType xsd:element
14
Hybrid Names in Namespaces (cont’d) xsd:group xsd:notation xsd:sequence xsd:simpleType xsd:group xsd:notation xsd:sequence xsd:simpleType
15
xsd:annotation Annotation is used to store extra information about the schema or its elements. These notes are specified for human consumption, xsd:documentation, or by software, xsd:appinfo. Annotation can be the first element of most Schema elements or anywhere under the schema element.
16
xsd:attribute Attributes provide additional information for other document elements. The attribute tag is nested in between the tags of a document’s element for the schema. The XML document displays attributes as named item in the opening tag of an element.
17
xsd:attributeGroup Groups a set of attribute declarations so that they can be incorporated as a group into complex type definitions.
18
xsd:complexType Defines a complex type that determines the set of attributes and content of an element.
19
xsd:element Used to describe an element in a XML document.
20
xsd:group Defines groups at the schema level that are referenced from the complex types. Groups a set of element declarations so that they can be incorporated as a group into complex type definitions.
21
xsd:notation An XML Schema definition language (XSD) notation declaration is a reconstruction of XML 1.0 NOTATION declarations. The purpose of notations is to describe the format of non-XML data within an XML document.
22
xsd:sequence Requires the elements in the group to appear in the specified sequence within the containing element.
23
xsd:simpleType Defines a simple type that determines the information and constraints for the values of attributes or elements with text-only content.
24
elementFormDefault Property Gets or sets the form for elements declared in the target namespace of the schema. Two values for this property: –Qualified Elements from the target namespace must be qualified with the namespace prefix. Unqualified Elements from the target namespace are not required to be qualified with the namespace prefix. Gets or sets the form for elements declared in the target namespace of the schema. Two values for this property: –Qualified Elements from the target namespace must be qualified with the namespace prefix. Unqualified Elements from the target namespace are not required to be qualified with the namespace prefix.
25
Element Types simpleType –Text only complexType –Can have sub-elements –Can have attributes simpleType –Text only complexType –Can have sub-elements –Can have attributes
26
Element Attributes abstract block final fixed Id maxOccurs abstract block final fixed Id maxOccurs
27
Element Attributes (cont’d) minOccurs name nillable substitutionGroup type minOccurs name nillable substitutionGroup type
28
Attribute Use Value can be: –required –optional –prohibited Value can be: –required –optional –prohibited
29
Facets A means for providing a more precise definition for data contained within a simple type or attribute
30
Example of a Facet
31
Other Schema Facets length minLength maxLength maxExclusive minExclusive length minLength maxLength maxExclusive minExclusive
32
Other Schema Facets (cont’d) duration totalDigits fractionDigits whiteSpace duration totalDigits fractionDigits whiteSpace
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.