Download presentation
Presentation is loading. Please wait.
Published byCameron Denholm Modified over 10 years ago
1
XML Schema 2005. 7. 14 Heewon Lee
2
Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion
3
DTD DTD (Document Type Definition) –Definition of the document structure with a list of legal elements –Internal or external declaration Why use a DTD? –Each document can carry its own format –For interchanging data, a common DTD can be used –Using DTD, applications can verify that data is valid Example 1. Introduction
4
XML Schema –Alternative to DTD –Description of the structure of an XML document –XML Schema language = XSD (XML Schema Definition) Why use XML Schema? –Supports data types –Uses XML syntax –Secures data communication –Extensible Example 1. Introduction
5
Referencing method Internal reference to DTD Reference to XML Schema External reference to DTD
6
1. Introduction Why XML Schema is better than DTD With the support for data types, it is easier to –Describe permissible document content –Validate the correctness of data –Work with data from a database –Define restrictions on data –Define data pattern (data formats) –Convert data between different data types. With the use of XML syntax, you –Dont have to learn another language –Can use your XML editor to edit your Schema files –Can use your XML parser to parse your Schema files. With an extensible Schema definition, you can –Reuse your Schema in other schemas –Create your own data types derived from standard types –Reference multiple schemas from the same document.
7
Framework of note.xsd... Root element Namespace should be prefixed xs Target namespace Default namespace Must be namespace qualified 2. Concepts
8
Referencing a schema <note xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xsi:schemaLocation="http://www.w3schools.com note.xsd"> Tove Jani Reminder Don't forget me this weekend! Default namespace XML Schema Instance namespace Namespace name Location of the XML Schema 2. Concepts
9
Simple Types XSD Elements –XML elements that can contain only text –Example XSD Attributes –If an element has attributes, its of complex type. Attribute itself is declared as a simple type. –Example XSD Restrictions –Used to control acceptable values for XML elements or attributes –Example 2. Concepts
10
Complex Types (1) A complex element contains other elements and/or attributes. 1. XSD Complex Empty Elements –Can contain attributes, but cannot have no content between the opening and closing tags –Example 2. XSD Complex Type Elements Only –Contains an element that contains only other elements –Example 2. Concepts
11
Complex Types (2) 3. XSD Complex Text-Only Elements –Can contain both attributes and text –Example 4. XSD Complex Types With Mixed Content –Can contain attributes, elements and text –Example 2. Concepts
12
Common XML Schema Data types xs:string xs:decimal xs:integer xs:boolean xs:data xs:time
13
XML Validation Test (1) 3. Example
14
XML Validation Test (2) <shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xsi:noNamespaceSchemaLocation="shiporder.xsd"> John Smith Ola Nordmann Langgt 23 4000 Stavanger Norway Empire Burlesque Special Edition 1 10.90 Hide your heart 1 9.90 shiporder.xsdshiporder.xml 3. Example
15
XML Validation Test (3) 3. Example
16
References Specifications –W3C Recommendation 28 October 2004 (http://www.w3.org/XML/Schema) XML Schema Part 0: Primer Second Edition XML Schema Part 1: Structures Second Edition XML Schema Part 2: Datatypes Second Edition Tutorial –XML Schema http://www.w3schools.com/schema/default.asp –XML DTD http://www.w3schools.com/dtd/default.asp
17
Conclusion XML Schema is better than DTA because of –Support for datatypes –High extensibility by using XML syntax XSD types –Simple Types –Complex Types 4. Conclusion
18
Q/A ? Question? ? ? ? ?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.