X-Informatics: I-400 and I-590 XML Schema

Slides:



Advertisements
Similar presentations
XMLSchema to TTCN-3 Mapping Importing XML schema based data types into TTCN-3.
Advertisements

Managing XML and Semistructured Data Lecture 12: XML Schema Prof. Dan Suciu Spring 2001.
4 XML Schema.
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
XML 6.5 XML Schema (XSD) 6. What is XML Schema? The origin of schema  XML Schema documents are used to define and validate the content and structure.
SDPL 2003Notes 2: Document Instances and Grammars1 2.5 XML Schemas n A quick introduction to XML Schema –W3C Recommendation, May 2, 2001: »XML Schema Part.
CSE 636 Data Integration XML Schema. 2 XML Schemas W3C Recommendation: Generalizes DTDs Uses XML syntax Two documents: structure.
XML Schema Definition Language
2/9/00 EECS 684: Current Topics in Databases1 ( W3C Working Draft 17 December 1999 )
XML Simple Types CSPP51038 shortcourse. Simple Types Recall that simple types are composed of text-only values. All attributes are of simple type Elements.
XML Schema Matthias Hauswirth. Agenda 4 W3C Process 4 XML Schema Requirements 4 The Specifications 4 Schema Tools.
1 XML Schemas Marco Mesiti This Presentation has been extracted from Roger L. Costello (XML Technologies Course)
XML Schemas and Namespaces Lecture 11, 07/10/02. BookStore.dtd.
Software Engineering Recitation 2 Suhit Gupta. Today we will be covering… XML II Sockets, Server – Client relationships, Servers capable of handling multiple.
XML Schemas. “Schemas” is a general term--DTDs are a form of XML schemas –According to the dictionary, a schema is “a structured framework or plan” When.
XML Schema Notes Lecture 13, 07/16/02. (see example05)
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
Introduction to XML Schema Winter Sources XML Schema Part 1: Structures W3C Recommendation 2 May 2001,
1 Print your own copy If you bring it along, hand in with your exam script Do not write anything extra or you will be penalized Student Name: Student Number:
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
17 Apr 2002 XML Schema Andy Clark. What is it? A grammar definition language – Like DTDs but better Uses XML syntax – Defined by W3C Primary features.
XML for E-commerce II Helena Ahonen-Myka. XML processing model n XML processor is used to read XML documents and provide access to their content and structure.
SDPL 2002Notes 2: Document Instances and Grammars1 2.5 XML Schemas n A quick introduction to XML Schema –W3C Recommendation, May 2, 2001: »XML Schema Part.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
IS432 Semi-Structured Data Lecture 3: XSchema Dr. Gamal Al-Shorbagy.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 1 Lecturer.
1 XML Schemas. 2 Useful Links Schema tutorial links:
Dr. Azeddine Chikh IS446: Internet Software Development.
Copyright © [2001]. Roger L. Costello. All Rights Reserved. 1 XML Schemas (Primer)
XML and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation.
Creating Data Schemas Presentation by Chad Borer 2/6/2006.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 2 Lecturer.
XML and Web Services CS409 Application Services Even Semester 2007.
SDPL 2005Notes 2.5: XML Schemas1 2.5 XML Schemas n Short introduction to XML Schema –W3C Recommendation, 1 st Ed. May, 2001; 2 nd Ed. Oct, 2004: »XML Schema.
XML. 2 XML- Some Links XML Tutorials – Some Links me=htmlhttp://
XML Schema. Why Schema? To define a class of XML documents Serve same purpose as DTD “Instance document" used for XML document conforming to schema.
Schemas 1www.tech.findforinfo.com. What is a Schema a schematic or preliminary plan Description of a structure, details... 2www.tech.findforinfo.com.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 5 XML Schema (Based on Møller and Schwartzbach,
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
Management of XML and Semistructured Data Lecture 11: Schemas Wednesday, May 2nd, 2001.
1 © The ATHENA Consortium. XML, eXtensible Markup Language (1) The format for structured information exchange. –Primary structuring is containment.
ITEC 4020A:Internet Client Server Systems Professor: Marin Litoiu Lecture 9&10 Web Service-XML © Marin Litoiu, York University, Canada.
Primer on XML Schema CSE 544 April, XML Schemas Generalizes DTDs Uses XML syntax Two parts: structure and datatypes Very complex –criticized –alternative.
QUALITY CONTROL WITH SCHEMAS CSC1310 Fall BASIS CONCEPTS SchemaSchema is a pass-or-fail test for document Schema is a minimum set of requirements.
Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
CSE 6331 © Leonidas Fegaras XML Schema 1 XML Schema Leonidas Fegaras.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML Schema Definition (XSD). Definition of a Schema It is a model for describing the structure and content of data The XML Schema was developed as a content.
Lecture 0 W3C XML Schema. Topics Status Motivation Simple type vs. complex type.
XML Schema – Simple Type Web site:
Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302.
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
eXtensible Markup Language
G52IWS: Extensible Markup Language (XML)
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
XML Technologies Instructors: Geoffrey Fox and Bryan Carpenter
Introduction to XML Schema DoD Users Group Tutorial on XML and Science
Design and Implementation of Software for the Web
.opennet Technologies XML Schema
Jagdish Gangolly State University of New York at Albany
THE DATATYPES OF XML SCHEMA A Practical Introduction
XML Technologies and Applications
DTD and XML Schema.
(with material by Suhit Gupta)
X-Informatics: I-400 and I-590 XML Schema
XML Schema Primer Seong Jong Choi Multimedia Lab.
CH 20 XML Schema.
Presentation transcript:

X-Informatics: I-400 and I-590 XML Schema Spring Semester 2002 MW 6:00 pm – 7:15 pm Indiana Time Geoffrey Fox and Bryan Carpenter PTLIU Laboratory for Community Grids Informatics, (Computer Science , Physics) Indiana University Bloomington IN 47404 gcf@indiana.edu 12/9/2018 xmlschemafall01

Outline XML Schema discussion based on http://www.w3.org/TR/xmlschema-0/ Note that this is reasonably complete – parts 1 and 2 (http://www.w3.org/TR/xmlschema-1/ etc.) are more formal discussions not extensions in coverage See http://www.w3schools.com/schema/ (elementary) and note very complete tutorial and examples at http://www.xfront.com/ We summarize all the topics in this primer Basic Schema Groups ** REMOVED Namespaces Include ** REMOVED Derived types ** REMOVED Import ** REMOVED Remember: Schema and DTD are like classes in Java XML files are instances of objects defined in Schema or DTD’s 12/9/2018 xmlschemafall01

XML Schema PO Example po.xml I <?xml version="1.0"?> <purchaseOrder orderDate="1999-10-20"> <shipTo country="US"> <name>Alice Smith</name> <street>123 Maple Street</street> <city>Mill Valley</city> <state>CA</state> <zip>90952</zip> </shipTo> <billTo country="US"> <name>Robert Smith</name> <street>8 Oak Avenue</street> <city>Old Town</city> <state>PA</state> <zip>95819</zip> </billTo> Need to add mechanism (namelist) to associate schema with this XML instance 12/9/2018 xmlschemafall01

XML Schema PO Example po.xml II <comment>Hurry, my lawn is going wild!</comment> <items> <item partNum="872-AA"> <productName>Lawnmower</productName> <quantity>1</quantity> <USPrice>148.95</USPrice> <comment>Confirm this is electric</comment> </item> <item partNum="926-AA"> <productName>Baby Monitor</productName> <USPrice>39.98</USPrice> <shipDate>1999-05-21</shipDate> </items> </purchaseOrder> 12/9/2018 xmlschemafall01

The Purchase Order Schema, po.xsd I <xsd:schema xmlns:xsd="http://www.w3.org/2000/08/XMLSchema"> <xsd:annotation> <xsd:documentation> Purchase order schema for Example.com. Copyright 2000 Example.com. All rights reserved. </xsd:documentation> </xsd:annotation> <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> <xsd:element name="comment" type="xsd:string"/> <xsd:complexType name="PurchaseOrderType"> <xsd:sequence> <xsd:element name="shipTo" type="USAddress"/> <xsd:element name="billTo" type="USAddress"/> <xsd:element ref="comment" minOccurs="0"/> <xsd:element name="items" type="Items"/> </xsd:sequence> <xsd:attribute name="orderDate" type="xsd:date"/> </xsd:complexType> 12/9/2018 xmlschemafall01

The Purchase Order Schema, po.xsd II <xsd:complexType name="USAddress"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="street" type="xsd:string"/> <xsd:element name="city" type="xsd:string"/> <xsd:element name="state" type="xsd:string"/> <xsd:element name="zip" type="xsd:decimal"/> </xsd:sequence> <xsd:attribute name="country" type="xsd:NMTOKEN" use="fixed" value="US"/> </xsd:complexType> 12/9/2018 xmlschemafall01

The Purchase Order Schema, po.xsd III <xsd:complexType name="Items"> <xsd:sequence> <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:element name="productName" type="xsd:string"/> <xsd:element name="quantity"> <xsd:simpleType> <xsd:restriction base="xsd:positiveInteger"> <xsd:maxExclusive value="100"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="USPrice" type="xsd:decimal"/> <xsd:element ref="comment" minOccurs="0"/> <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> </xsd:sequence> <xsd:attribute name="partNum" type="SKU"/> </xsd:complexType> Anonymous type quantity Specify item 12/9/2018 xmlschemafall01

The Purchase Order Schema, po.xsd IV </xsd:element> <!– End item specification  </xsd:sequence> <!– End sequence for items specification  </xsd:complexType> <!– End items specification  <!-- Stock Keeping Unit, a code for identifying products --> <xsd:simpleType name="SKU"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\d{3}-[A-Z]{2}"/> </xsd:restriction> </xsd:simpleType> </xsd:schema> 12/9/2018 xmlschemafall01

Comments on po.xsd I The prefix xsd: is Namespace specified by xmlns:xsd=“http://www.w3.org/2000/08/XMLSchema” The label xsd is conventional; you could use a different one Schema does two types of things: Defines new types of elements or attributes e.g. PurchaseOrderType with xsd:complexType or xsd:simpleType Defines internal elements and attributes for tags e.g. PurchaseOrder using xsd:element and xsd:attribute So an element like shipTo in po.xml has at most one attribute country which if it appears must have value US. The elements name, street, city, state, zip must appear in this order and the first four are strings; zip is a xsd:decimal 12/9/2018 xmlschemafall01

Comments on po.xsd II The prefix xsd: is Namespace specified by xmlns:xsd=http://www.w3.org/2000/08/XMLSchema The label xsd is conventional; you could use a different one 12/9/2018 xmlschemafall01

Comments on po.xsd III Schema does two types of things: Defines new types of elements or attributes e.g. PurchaseOrderType with xsd:complexType Defines internal elements and attributes for tags e.g. PurchaseOrder using xsd:element and xsd:attribute 12/9/2018 xmlschemafall01

Comments on po.xsd IV So an element like shipTo in po.xml has at most one attribute country which if it appears must have value US. The elements name, street, city, state, zip must appear in this order and the first four are strings; zip is a xsd:decimal 12/9/2018 xmlschemafall01

xsd:complexType Example Anything of PurchaseOrderType is allowed one attribute (orderDate) of type xsd:date. Further it must consists of 4 elements shipTo, billTo, comment and items in that order comment can be absent as minOccurs = 0 Note that comment is a global element defined in the schema. It is accessed by ref= rather than type= One can define global elements or attributes which cannot themselves use ref (global elements are particularly important if one imports this schema into other schema as only global components can be re-used) minOccurs and maxOccurs have default values of 1 and so shipTo, billTo and items must appear once and once only 12/9/2018 xmlschemafall01

Specifying xsd:element and xsd:attribute Any xsd:element tag can have attribute minOccurs, maxOccurs, fixed and default Any xsd:attribute can have attribute use and value Note attributes can NEVER appear more than once - means not present 12/9/2018 xmlschemafall01

Simple Types Attributes must be Simple Types; Elements can be complex types or simple types Simple types cannot themselves have attributes or contain other elements The xsd:restriction tag allows you to build new simple types by adding constraints to existing simple types. These constraints are specified by a set of “constraining facets” xsd:minInclusive and xsd:maxInclusive restrict 10000 <= myInteger <= 99999 xsd:pattern restricts using a regular expression to 3 single digits followed by two capital letters 12/9/2018 xmlschemafall01

Constraining Facets These are defined in http://www.w3.org/TR/2000/CR-xmlschema-2-20001024/ and are length, minLength, maxLength, pattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minExclusive, minInclusive, precision, scale, encoding, duration, period Tables tell you which constraining facets can be used with which simple type enumeration can be used with all simple types except boolean. In example below, you could define a USState simple type which could take any of conventional abbreviations of the US States 12/9/2018 xmlschemafall01

Simple Types Built In to XML Schema I Simple Type Examples (delimited by commas) Red is Note string Confirm this is electric CDATA Confirm this is electric (white space(tabs) to blanks etc.) token Confirm this is electric (trailing/leading white space removed) byte -1, 126 unsignedByte 0, 126 binary 62696E617279 integer -126789, -1, 0, 1, 126789 positiveInteger 1, 126789 negativeInteger -126789, -1 nonNegativeInteger 0, 1, 126789 nonPositiveInteger -126789, -1, 0 int -1, 126789675 unsignedInt 0, 1267896754 long -1, 12678967543233 unsignedLong 0, 12678967543233 short -1, 12678 unsignedShort 0, 12678 12/9/2018 xmlschemafall01

Simple Types Built In to XML Schema II decimal -1.23, 0, 123.4, 1000.00 float -INF, -1E4, -0, 0, 12.78E-2, 12, INF, NaN double -INF, -1E4, -0, 0, 12.78E-2, 12, INF, NaN boolean true, false time 13:20:00.000, 13:20:00.000-05:00 timeInstant 1999-05-31T13:20:00.000-05:00 [May 31st 1999 at 1.20pm Eastern Standard Time which is 5 hours behind Coordinated Universal Time] timePeriod 1999-05-31T13:20 timeDuration P1Y2M3DT10H30M12.3S [1 year, 2 months, 3 days, 10 hours, 30 minutes, 12.3 seconds] date 1999-05-31 month 1999-05 [May 1999] year 1999 [1999] century 19 [the 1900's] recurringDay ----31 [every 31st day] recurringDate --05-31 [every May 31st] recurringDuration --05-31T13:20:00 [May 31st every year at 1.20pm Coordinated Universal Time, format similar to timeInstant] Red is Note 12/9/2018 xmlschemafall01

Simple Types Built In to XML Schema III Simple Type Examples (delimited by commas) Notes in [] Name shipTo [XML 1.0 Name type] QName po:USAddress [XML Namespace QName] NCName USAddress [XML Namespace NCName, i.e. a QName without the prefix and colon] uriReference http://www.example.com/, http://www.example.com/doc.html#ID5 language en-GB, en-US, fr [valid values for xml:lang as defined in XML 1.0] ID [XML 1.0 ID attribute type] IDREF [XML 1.0 IDREF attribute type] IDREFS [XML 1.0 IDREFS attribute type] ENTITY [XML 1.0 ENTITY attribute type] ENTITIES [XML 1.0 ENTITIES attribute type] NOTATION [XML 1.0 NOTATION attribute type] NMTOKEN US, Brésil [XML 1.0 NMTOKEN attribute type] NMTOKENS US UK, Brésil Canada Mexique [XML 1.0 NMTOKENS attribute type, i.e. a whitespace separated list of NMTOKEN's] 12/9/2018 xmlschemafall01

Schema and Namespaces Schema do a better job than DTD in making it clear how Namespaces can be used effectively Here we define http://www.example.com/PO1 as the targetNamespace for this schema We also define po: as the same URL and the default Namespace to be W3C Schema central Then we do NOT need xsd: as in original po.xml as we have set Schema central to be default In name=‘..’, we do NOT need to specify a Namespace but in type=“..” or ref=“..” we do not as these could reference another Namespace No Namespace as string type define in Schema Central 12/9/2018 xmlschemafall01