Upload
ismael
View
60
Download
0
Embed Size (px)
DESCRIPTION
Enterprise IT [Πληροφοριακές Τεχνολογίες της Επιχείρησης] Lecture 6-9: XSD Overview Univ. of the Aegean Financial and Management Engineering Dpt. Petros KAVASSALIS. What you will learn in this course. - PowerPoint PPT Presentation
Citation preview
1
Enterprise IT[Πληροφοριακές Τεχνολογίες της Επιχείρησης]
Lecture 6-9: XSD Overview
Univ. of the Aegean Financial and Management Engineering Dpt
Petros KAVASSALIS<[email protected]>
What you will learn in this course
A set of fundamental concepts for understanding basic Enterprise Information Technologies Enterprise Software Applications Enterprise Architecture Integration (EAI)
Best practices and techniques for building and migrating to a service-oriented enterprise
Strategies for integrating applications using standard technologies XML Web Services
Familiarization with concepts such as: Interoperability e-business e-government 2.0
Communication tools
e-mail: [email protected] Course web site: see FME web site
Students evaluation
Class Participation (20%)
+ Assignments (20%)
+ Final Exam (650%)
First go to http://www.w3schools.com/Schema/default.asp
XSD in a nutshell
XML: XML Schema Definition Language XML Working Group at W3C (please visit!)
Used for the definition of XML tags and structure … the content and the structure of a class of XML documents
Schemas provide capabilities for expressing XML documents (the “logical structure” of the XML document Support for metadata characteristics
o Relationshipso Cardinalityo Valid Valueso Data Types
XML documents without a referenced schema cannot be “validated” If validated, the XML document has a valid construction… Note: “Simple”, “short” XML documents do not necessarily require the use of an XSD
scheme
XSD: components
Schema components = building blocks Elements declarations Attribute declarations Simple Type definitions Complex Type definitions Notifications etc…
XSD: architecture (1)
<?xml version=“1.0” encoding=“UTF-8”?><xsd:schema>
NAMESPACE
BODY</xsd/schema>
Root element
XSD: architecture (2)
<[email protected]> 9J. Bean (2003)
XSD: Global and Local Elements
Global Elements: Available to be used in the rest of the schema They are declared at the top level of the schema (BODY)
o This declaration determines how the element will look like They are “referenced” each time we want to use somewhere in the
schema Local Elements: Elements “on the spot”
They may not be used elsewhere in the schema Their names are “locally” unique, i.e. unique only in the context in
which they appear
<[email protected]> 10
XSD: Simple Types
Elements with a built-in Type <xsd:element name=“label”
type=“xsd:datatype”/> xml
<label>data</label>
<xsd:element name=“weight” type=“xsd:string”/>
xml <weight>200 kg</weight>
Custom Simple Types <xsd:simpleType
name=“kapaType”><xsd:restriction
base=“xsd:datatype”><xsd:pattern value=“pattern”/></xsd:restriction>
</xsd:simpleType> xml
<kapa>data</kapa>
<[email protected]> 11
XSD: Simple TypesExample
<xsd:element name="car" type="carType"/>
<xsd:simpleType name="carType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Audi"/> <xsd:enumeration value="Golf"/> <xsd:enumeration value="BMW"/> </xsd:restriction></xsd:simpleType>
<[email protected]> 12
XSD: built-in DataTypes and limitations for Simple Types
Data and Time Types (built-in) Number Types (built-in) Other built-in Types
Locate them
Acceptable Values foe simple Types Patterns for simple Types Range of Acceptable Values for simple Types Length Limits for simple Types Number’s Digits Length for simple Types
List Types Element’s Content: pre-definition
<[email protected]> 13
XSD: Restrictions/Facets for Datatypes
http://www.w3schools.com/Schema/schema_elements_ref.asp Restrictions/Facets for Datatypes
<[email protected]> 14
XSD: Complex Types
<[email protected]> 15
Complex Types
<xsd:complexType name=“kapaType”><xsd:sequence><xsd:element name=“lamda”
type=”lamdaType”/></xsd:sequence>
</xsd:complexType
Simple Types
<xsd:simpleType name=“kapaType”><xsd:restriction
base=“xsd:datatype”><xsd:pattern value=“pattern”/></xsd:restriction>
</xsd:simpleType> xml
<kapa>data</kapa>
XSD: Complex TypesExplicitly naming the xml element (restricted)
xml<employee>
<firstname>John</firstname> <lastname>Smith</lastname>
</employee> xsd
<xsd:element name="employee"> <xsd:complexType> <xsd:sequence> <xsd:element name="firstname" type="xsd:string"/> <xsd:element name="lastname" type="xsd:string"/> </xsd:sequence> </xsd:complexType>
</xsd:element><[email protected]> 16
XSD: Complex TypesSeveral elements can refer to a complex type
xml<employee>
<firstname>John</firstname> <lastname>Smith</lastname>
</employee> xsd
<xsd:element name="employee" type="personinfo"/><xsd:complexType name="personinfo"> <xs:dsequence> <xsd:element name="firstname" type="xsd:string"/> <xsd:element name="lastname" type="xsd:string"/> </xsd:sequence></xsd:complexType>
<[email protected]> 17
XSD: Complex TypesExtend a complex element
<[email protected]> 18
<xsd:element name="employee" type="fullpersoninfo"/>
<xsd:complexType name="personinfo"> <xsd:sequence> <xsd:element name="firstname" type="xsd:string"/> <xsd:element name="lastname" type="xsd:string"/> </xsd:sequence></xsd:complexType>
<xsd:complexType name="fullpersoninfo"> <xsd:copmlexContent> <xsd:extension base="personinfo"> <xsd:sequence> <xsd:element name="address" type="xsd:string"/> <xsd:element name="city" type="xsd:string"/> <xsd:element name="country" type="xsd:string"/> </xsd:sequence> </xsd:extension> </xsd:complexContent></xsd:complexType>
XSD: Complex TypesXSD Elements
http://www.w3schools.com/Schema/schema_elements_ref.asp XSD Elements
<[email protected]> 19
Set of choices Elements appearing with no order Max-Min Occurs Groups of elements
Referencing a named group How many elements?
XSD Attributes xml
o <lastname lang="EN">Smith</lastname> xsd
o <xsd:attribute name="lang" type="xsd:string"/>
XSD: Complex TypesChoice, Order and Groups
<[email protected]> 20
XSD: Complex TypesEmpty Elements
Empty Elements xml
o <product prodid="1345" /> xsd
o <xsd:element name="product"> <xsd:complexType> <xsd:attribute name="prodid" type="xsd:positiveInteger"/> </xsd:complexType></xsd:element>
xsd (2)o <xsd:element name="product" type="prodtype"/>4
<xsd:complexType name="prodtype"> <xsd:attribute name="prodid" type="xsd:positiveInteger"/></xsd:complexType>
<[email protected]> 21
XSD: Complex TypesElements with Mixed Content
Text-Only Elements (text, attributes)
<xsd:element name="somename"> <xsd:complexType <xsd:simpleContent> <xsd:extension base="basetype"> .... .... </xsd:extension> </xsd:simpleContent> </xsd:complexType></xsd:element>
Mixed Elements xml
<letter> Dear Mr.<name>John Smith</name>. Your order <orderid>1032</orderid> will be shipped on <shipdate>2001-07-13</shipdate>.</letter>
xsd <xsd:element name="letter" type="lettertype"/>
<xsd:complexType name="lettertype" mixed="true"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="orderid" type="xsd:positiveInteger"/> <xsd:element name="shipdate" type="xsd:date"/> </xsd:sequence></xsd:complexType><[email protected]> 22
XSD: Simple & Complex Types
All in One http://www.codeguru.com/java/article.php/c13529 (*) http://www.learn-xml-schema-tutorial.com/
<[email protected]> 24
XSD: Complex TypesExamples
http://www.w3schools.com/Schema/schema_example.asp http://www2.it.lut.fi/kurssit/08-09/CT30A2900/Lectures/Exam
ples/An XML schema example.pdf
<[email protected]> 25
[References]
E. Castro, 2001, XML for the World Wide Web, Peachpit Press Chapters 5, 6, 7, 8, 9
J. Bean, 2003, XML for Data Architects, Morgan Kaufmann Pub. Chapter 4
<[email protected]> 26