1 / 26

Petros KAVASSALIS

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.

ismael
Download Presentation

Petros KAVASSALIS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Enterprise IT[Πληροφοριακές Τεχνολογίες της Επιχείρησης]Lecture 6-9: XSD OverviewUniv. of the Aegean Financial and Management Engineering Dpt Petros KAVASSALIS

  2. What you will learn in this course • A set offundamentalconceptsfor 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

  3. Communication tools • e-mail: pkavassalis@atlantis-group.gr • Course web site: see FME web site

  4. Students evaluation • Class Participation (20%) + • Assignments (20%) + • Final Exam (650%)

  5. First go to http://www.w3schools.com/Schema/default.asp

  6. 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 • Relationships • Cardinality • Valid Values • 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

  7. XSD: components • Schema components = building blocks • Elements declarations • Attribute declarations • Simple Type definitions • Complex Type definitions • Notifications • etc…

  8. XSD: architecture (1) <?xml version=“1.0” encoding=“UTF-8”?> <xsd:schema> NAMESPACE BODY </xsd/schema> Root element

  9. XSD: architecture (2) J. Bean (2003)

  10. 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) • 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

  11. XSD: Simple Types  Elements with a built-in Type  Custom Simple Types <xsd:simpleType name=“kapaType”> <xsd:restriction base=“xsd:datatype”> <xsd:pattern value=“pattern”/> </xsd:restriction> </xsd:simpleType> xml <kapa>data</kapa> • <xsd:element name=“label” type=“xsd:datatype”/> • xml • <label>data</label> • <xsd:element name=“weight” type=“xsd:string”/> • xml • <weight>200 kg</weight>

  12. 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>

  13. 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

  14. XSD: Restrictions/Facets for Datatypes • http://www.w3schools.com/Schema/schema_elements_ref.asp • Restrictions/Facets for Datatypes

  15. XSD: Complex Types •  Simple Types •  Complex Types • <xsd:simpleType name=“kapaType”> <xsd:restriction base=“xsd:datatype”> <xsd:pattern value=“pattern”/> </xsd:restriction> </xsd:simpleType> • xml • <kapa>data</kapa> • <xsd:complexType name=“kapaType”> <xsd:sequence> <xsd:element name=“lamda” type=”lamdaType”/> </xsd:sequence> </xsd:complexType

  16. 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>

  17. 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>

  18. XSD: Complex TypesExtend a complex element • <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>

  19. XSD: Complex TypesXSD Elements • http://www.w3schools.com/Schema/schema_elements_ref.asp • XSD Elements

  20. XSD: Complex TypesChoice, Order and Groups • Set of choices • Elements appearing with no order • Max-Min Occurs • Groups of elements • Referencing a named group • How many elements? • XSD Attributes • xml • <lastnamelang="EN">Smith</lastname> • xsd • <xsd:attribute name="lang" type="xsd:string"/>

  21. XSD: Complex TypesEmpty Elements • Empty Elements • xml • <product prodid="1345" /> • xsd • <xsd:element name="product">  <xsd:complexType>    <xsd:attribute name="prodid" type="xsd:positiveInteger"/>  </xsd:complexType></xsd:element> • xsd (2) • <xsd:element name="product" type="prodtype"/>4<xsd:complexType name="prodtype">  <xsd:attribute name="prodid" type="xsd:positiveInteger"/></xsd:complexType>

  22. XSD: Complex TypesElements with Mixed Content Text-Only Elements (text, attributes) 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> • <xsd:element name="somename">  <xsd:complexType    <xsd:simpleContent>      <xsd:extension base="basetype">        ....        ....      </xsd:extension>    </xsd:simpleContent>  </xsd:complexType></xsd:element>

  23. XSD: Complex TypesMore • <any> • <anyAttribute> • Substitution

  24. XSD: Simple & Complex Types • All in One • http://www.codeguru.com/java/article.php/c13529(*) • http://www.learn-xml-schema-tutorial.com/

  25. XSD: Complex TypesExamples • http://www.w3schools.com/Schema/schema_example.asp • http://www2.it.lut.fi/kurssit/08-09/CT30A2900/Lectures/Examples/An XML schema example.pdf

  26. [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

More Related