Session III Chapter 10 – Defining Simple Types

Slides:



Advertisements
Similar presentations
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Advertisements

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.
Excel Chapter 6 Review slides. How many worksheets are in a workbook, by default? three.
1 XML DTD & XML Schema Monica Farrow G30
XML Schema Definition Language
XML Simple Types CSPP51038 shortcourse. Simple Types Recall that simple types are composed of text-only values. All attributes are of simple type Elements.
1 Week5 – Schema Why Schema? Schemas vs. DTDs Introduction – W3C vs. Microsoft XDR Schema, How To? Element Types – Simple vs. Complex Attributes Restrictions/Facets.
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.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
1 XML Schema Information Retrieval Systems Maria Indrawan 2003.
XML Schema Describing the structure of XML documents. A very brief introduction 1XML Schema.
Introduction to XML This material is based heavily on the tutorial by the same name at
Entering Data in Excel. Entering numbers, text, a date, or a time n 1Click the cell where you want to enter data. n 2Type the data and press ENTER or.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
Language Recognizer Connecting Type 3 languages and Finite State Automata Copyright © – Curt Hill.
Session III Chapter 7 – Entities and Notation in DTD’s
XML Schema Vinod Kumar Kayartaya. What is XML Schema?  XML Schema is an XML based alternative to DTD  An XML schema describes the structure of an XML.
1 XML Schemas. 2 Useful Links Schema tutorial links:
Dr. Azeddine Chikh IS446: Internet Software Development.
Li Tak Sing COMPS311F. XML Schemas XML Schema is a more powerful alternative to DTD to describe XML document structures. The XML Schema language is also.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
1 Dr Alexiei Dingli XML Technologies X-Schema. 2 XML-based alternative to DTD Describes the structure of an XML document Also referred to as XML Schema.
Session IV Chapter 9 – XML Schemas
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
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.
August Chapter 4 - Quality Control with Schemas Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and.
Regular Expressions Regular expressions are a language for string patterns. RegEx is integral to many programming languages:  Perl  Python  Javascript.
New Perspectives on XML, 2nd Edition
The One-to-many Relationship A relationship in which one object can reference several instances of another.
1 CSC 594 Topics in AI – Text Mining and Analytics Fall 2015/16 4. Document Search and Regular Expressions.
Regular Expressions CSC207 – Software Design. Motivation Handling white space –A program ought to be able to treat any number of white space characters.
Regular Expressions.
Schemas 1www.tech.findforinfo.com. What is a Schema a schematic or preliminary plan Description of a structure, details... 2www.tech.findforinfo.com.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
XML – Part III. The Element … This type of element either has the element content or the mixed content (child element and data) The attributes of the.
XSD Presented by Kushan Athukorala. 2 Agenda XML Namespaces XML Schema XSD Indicators XSD Data Types XSD Schema References.
When you read a sentence, your mind breaks it into tokens—individual words and punctuation marks that convey meaning. Compilers also perform tokenization.
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
GREP. Whats Grep? Grep is a popular unix program that supports a special programming language for doing regular expressions The grammar in use for software.
EGEE is a project funded by the European Union under contract IST XML Schema 3 – 4 June
CS 157B: Database Management Systems II February 18 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
QUALITY CONTROL WITH SCHEMAS CSC1310 Fall BASIS CONCEPTS SchemaSchema is a pass-or-fail test for document Schema is a minimum set of requirements.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Operators Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
CSE3201 Information Retrieval Systems XML Schema – Part 2.
XML Schema – Simple Type Web site:
OOP Tirgul 11. What We’ll Be Seeing Today  Regular Expressions Basics  Doing it in Java  Advanced Regular Expressions  Summary 2.
Lesson 4 String Manipulation. Lesson 4 In many applications you will need to do some kind of manipulation or parsing of strings, whether you are Attempting.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
CS314 – Section 5 Recitation 2
Regular Expressions in Perl
CMP 051 XML Introduction Session IV
RELAX NG 2-Aug-18.
RELAX NG 18-Sep-18.
Session III Chapter 6 – Creating DTDs
Design and Implementation of Software for the Web
THE DATATYPES OF XML SCHEMA A Practical Introduction
CMP 051 XML Introduction Session IV Chapter 10 – Defining Simple Types
DTD and XML Schema.
CMP 051 XML Introduction Session III
XML Technologies X-Schema.
RELAX NG 19-Feb-19.
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Kirkwood Center for Continuing Education
Session II Chapter 6 – Creating DTDs
Presentation transcript:

Session III Chapter 10 – Defining Simple Types

Outline XML Simple Element Types Defining a Simple Element Type Using Date and Time Types Using Number Types Predefining an Element Content Deriving Custom Simple Types Deriving Named Custom Types Specifying a Range of Acceptable Values Specifying a Set of Acceptable Values Limiting the Length of an Element Specifying the Pattern for an Element Limiting a Number’s Digits Deriving a List Type Deriving a Union Type 8/1/2014Copyright © Carl M. Burnett2

XML Simple Element Types XML simple element contains only text. Cannot contain any other elements or attributes. Most common built-in data types: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time 8/1/2014Copyright © Carl M. Burnett3

Defining a Simple Element Type 8/1/2014Copyright © Carl M. Burnett4 1.Type <xs:element to begin the definition. 2.Type name-”label” where label is the name of the XML element that you are defining. 3.Type types=“ 4.Type the following to identify the simple data types: xs:string for string of characters. xs:decimal for decimal number. xs:boolean for true / false. xs:date for a date. xs:time for time. xs:anyURI for a reference to a file. 5.Type > to complete the definition.

Using Date and Time Types 8/1/2014Copyright © Carl M. Burnett5 SyntaxFormat xs:gYear YYYY xs:gYearMonth YYYY-MM xs:gMonth --MM xs:gMonthDay --MM—DD xs:gDay --DD SyntaxFormat xs:date YYYY-MM-DD xs:time hh:mm:ss xs:dateTime YYYY:MM:DDThh:mm:ss xs:duration PnYnMnDTnHnMnS Where: P stands for Period T only required for time units Y – Years M – Months D – Days H – Hours M – Minutes S – Seconds

Using Number Types 8/1/2014Copyright © Carl M. Burnett6 SyntaxFormat xs:byte A signed 8-bit integer xs:decimal 4.26, -100, or 0 xs:int A signed 32-bit integer xs:integer 542 or -7 xs:positiveInteger 1, 2 xs:negativeInteger 0, -1,-2 xs:nonPositiveInteger 0,-1,-2 xs:nonNegativeInteger 0,1,2 SyntaxFormat xs:float 32-bit floating point numbers xs:short 32-bit integer xs:unsignedLong An unsigned 64-bit integer xs:unsignedInt An unsigned 32-bit integer xs:unsignedShort An unsigned 32-bit integer xs:unsignedByte An unsigned 32-bit integer

Predefining an Element Content 8/1/2014Copyright © Carl M. Burnett7 1.Within the element tag type fixed=. 2.Type ”value” where value is what the element must be equal to in order to be considered valid. To Set an Element’s Value To Set an Element’s Default Value 1.Within the element tag type default=. 2.Type ”value” where value is what the element will equal to if empty or omitted.

Deriving Custom Simple Types 8/1/2014Copyright © Carl M. Burnett8 1.Identify the name of the XML element that you are using an XML Schema to define. 2.To do so type where label is the name of the XML element. 3.Type to start deriving your custom simple type. 4.Type where foundation is any of the built-in simple types you want to base your custom type. 5.Specify as many restrictions (or facets) as necessary to define your new custom type. 6.Type 7.Type 8.Type to complete the definition of the element.

Deriving Named Custom Types 8/1/2014Copyright © Carl M. Burnett9 1.Type <xs:simpleType to start the simple custom type. 2.Type where custom_type_name identifies your new custom simple type. 3.Type where foundation is the simple type upon which you are building your custom type. 4.Specify as many restrictions (or facets) as necessary to define your new custom type. 5.Type 6.Type 7.To use your new custom type using custom_type_name you gave your new custom type.

Specifying a Range of Acceptable Values 8/1/2014Copyright © Carl M. Burnett10 To specify the highest possible value Another way to specify the highest possible value 1.Within a custom type definition type <xs:maxInclusive 2.Then, type value="n“, where the element’s content must be less than or equal to n in order to be valid. 3.Finally, type /> to complete the xs:maxInclusive facet. 1. Within a custom type definition type <xs:maxExclusive 2. Then, type value="n", where the element’s content must be less than (but not equal to) n in order to be valid. 3. Finally, type /> to complete the xs:maxExclusive facet.

Specifying a Range of Acceptable Values 8/1/2014Copyright © Carl M. Burnett11 To specify the lowest possible value Another way to specify the lowest possible value 1.Within a custom type definition type <xs:mimInclusive 2.Then, type value="n“, where the element’s content must be less than or equal to n in order to be valid. 3.Finally, type /> to complete the xs:minInclusive facet. 1. Within a custom type definition type <xs:minExclusive 2. Then, type value="n", where the element’s content must be less than (but not equal to) n in order to be valid. 3. Finally, type /> to complete the xs:minExclusive facet.

Specifying a Set of Acceptable Values 8/1/2014Copyright © Carl M. Burnett12 1. Within a custom type definition, type <xs:enumeration. 2. Then, type value="choice", to identify one acceptable choice for the content of the element or attribute. 3. Finally, type /> to complete the xs:enumeration element. 4. Repeat Steps 1–3 for each addition

Limiting the Length of an Element 8/1/2014Copyright © Carl M. Burnett13 To specify the exact length of an element Within a custom type definition type, where g is the number of characters that the element must have. To specify the Minimum length of an element Within a custom type definition type, where n is the minimum length of characters that the element must have. To specify the Maximum length of an element Within a custom type definition type, where x is the maximum length of characters that the element must have.

Specifying the Pattern for an Element 8/1/2014Copyright © Carl M. Burnett14 1.Within a custom type definition type <xs:pattern. 2.Then, type value="regex", where regex is the regular 3.expression that the XML element’s content must match. Regular expressions are made up of letters, numbers, and special symbols; in the order which those letters, numbers, and symbols should appear in the content. Symbols include:. (a period) for any character at all. \d for any digit; \D for any non-digit. \s for any white space (including space, tab, newline, and return); \S for any character that is not white space. x* to have zero or more x’s; (xy)* to have zero or more xy’s. x? to have zero or one x; (xy)? to have zero or one xy. x+ to have one or more x’s; (xy)+ to have one or more xy’s. [abc] to include one of a group of values (a, b, or c). [0–9] to include the range of values from 0 to 9.

Specifying the Pattern for an Element 8/1/2014Copyright © Carl M. Burnett15 1.Within a custom type definition type <xs:pattern. 2.Then, type value="regex", where regex is the regular expression that the XML element’s content must match. Regular expressions are made up of letters, numbers, and special symbols; in the order which those letters, numbers, and symbols should appear in the content. 3. Finally, type /> to complete the xs:pattern element. Symbols include:. (a period) for any character at all. \d for any digit; \D for any non-digit. \s for any white space (including space, tab, newline, and return); \S for any character that is not white space. x* to have zero or more x’s; (xy)* to have zero or more xy’s. x? to have zero or one x; (xy)? to have zero or one xy. x+ to have one or more x’s; (xy)+ to have one or more xy’s. [abc] to include one of a group of values (a, b, or c). [0–9] to include the range of values from 0 to 9. this | that to have this or that in the content. Separate additional choices with additional vertical bars. x{5} to have exactly 5 x’s (in a row). x{5,} to have at least 5 x’s (in a row). x{5,8} to have at least 5 and at most 8 x’s (in a row). (xyz){2} to have exactly two xyz’s (in a row). Note: Parentheses control what the curly brackets and other modifiers, such as ?, +, and *, affect.

Specifying the Pattern for an Element 8/1/2014Copyright © Carl M. Burnett16

Limiting a Number’s Digits 8/1/2014Copyright © Carl M. Burnett17 To specify the total number of digits in a number To specify the number of digits after the decimal point 1. Within a custom type definition type <xs:totalDigits. 2. Then, type value="n", where n is the maximum number of digits that can appear in the number. 3. Finally, type /> to complete the xs:totalDigits facet. 1. Within a custom type definition type <xs:fractionDigits. 2. Then, type value="n", where n is the maximum number of digits that can appear after the decimal in the number. 3. Finally, type /> to complete the xs:fractionDigits facet.

Deriving a List Type 8/1/2014Copyright © Carl M. Burnett18 1.First, identify the name of the XML element that you are using XML Schema to define. 2.Type, where label is the name of the XML element. 3.Type to start deriving your custom simple type. 4.Type, where list_element is the simple type (built in or custom) that defines each individual unit in your list. 5.Type to complete your new custom simple type. 6.Type to complete the definition of the element.

Deriving a Union Type 8/1/2014Copyright © Carl M. Burnett19 1.First, identify the name of the XML element that you are using XML Schema to define. 2.Type, where label is the name of the XML element. 3.Type to start your custom simple type. 4.Type, where union_elements is a white-space-separated group of simple types (built-in or custom) that define the valid simple types for this element. 5.Type to complete your new custom simple type. 6.Type to complete the definition of the element.

Review XML Simple Element Types Defining a Simple Element Type Using Date and Time Types Using Number Types Predefining an Element Content Deriving Custom Simple Types Deriving Named Custom Types Specifying a Range of Acceptable Values Specifying a Set of Acceptable Values Limiting the Length of an Element Specifying the Pattern for an Element Limiting a Number’s Digits Deriving a List Type Deriving a Union Type 8/1/2014Copyright © Carl M. Burnett20 Next: Chapter 11 – Complex Types