4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.

Slides:



Advertisements
Similar presentations
XML Schema Heewon Lee. Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion.
Advertisements

What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
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:
Copyright © Open Applications Group, Inc. All rights reserved 1 OAGi XML Schema User Report June 21, Michael.
1 XML DTD & XML Schema Monica Farrow G30
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.
An Introduction to XML Schema CSCI 7818 by Ming Rutar.
XML Schemas Lecture 10, 07/10/02. Acknowledgements A great portion of this presentation has been borrowed from Roger Costello’s excellent presentation.
COS 381 Day 17. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
DECO 3002 Advanced Technology Integrated Design Computing Studio Tutorial 6 – XML Schema School of Architecture, Design Science and Planning Faculty of.
Enabling Grids for E-sciencE ISSGC’05 XML Schemas (XSD) Richard Hopkins, National e-Science Centre, Edinburgh June 2005.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
XML Schema Basics SD2520 Databases using XML and Jquery Chapter 12
Unit 4 – XML Schema XML - Level I Basic.
XML Schemas J. Pontes November 15, Schemas  Defines what a set of one or more document can look like.  What elements it contains, order, content,
Introduction to XML This material is based heavily on the tutorial by the same name at
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.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
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.
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.
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.
Copyright © [2001]. Roger L. Costello. All Rights Reserved. 1 XML Schemas (Primer)
Neminath Simmachandran
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Schemas Ellen Pearlman Eileen Mullin Programming the Web Using XML.
XML and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation.
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.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Session IV Chapter 9 – XML Schemas
1 Introduction to Web Application Introduction to XML.
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.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
Beginning XML 4th Edition. Chapter 5: XML Schemas.
New Perspectives on XML, 2nd Edition
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.
An OO schema language for XML SOX W3C Note 30 July 1999.
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.
An Introduction to XML Sandeep Bhattaram
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.
COS 381 Day 14. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
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
XML Schema. Why Validate XML? XML documents can generally have any structure XML grammars define specific document structures Validation is the act of.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
Working with XML Schemas ©NIITeXtensible Markup Language/Lesson 3/Slide 1 of 36 Objectives In this lesson, you will learn to: * Declare attributes in an.
XML Schema (W3C) Thanks to Jussi Pohjolainen TAMK University of Applied Sciences.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
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.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
CITA 330 Section 4 XML Schema. XML Schema (XSD) An alternative industry standard for defining XML dialects More expressive than DTD Using XML syntax Promoting.
XML SCHEMA 1 CH 20. Objective 2 What’s wrong with DTDs? What is a schema? The W3C XML Schema Language Hello schemas Complex types Simple types Deriving.
MSc in Communication Sciences Program in Technologies for Human Communication Davide Eynard Facoltà di scienze della comunicazione Università.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
G52IWS: Extensible Markup Language (XML)
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
ece 720 intelligent web: ontology and beyond
New Perspectives on XML
Presentation transcript:

4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema

4-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Describe XML Schema Create an XML Schema document Reference an XML Schema in an XML document Create an XML Schema document by using: –Built-in data types –Simple types –Complex types with sequences and choices Validate XML documents with XML Schema by using: –The oraxml command-line utility –Oracle JDeveloper 10g

4-3 Copyright © 2004, Oracle. All rights reserved. What Is an XML Schema? XML Schema Is an XML language that defines and validates the structure of XML documents Is stored in an XML Schema Document (XSD) Defines components, such as: –Simple types definitions –Complex type definitions –Element declarations –Attribute declarations Supports XML Namespaces, and built-in, simple, and complex data types XSD Validates References Instance

4-4 Copyright © 2004, Oracle. All rights reserved. The Benefits of XML Schemas XML Schemas: Unify both document and data modeling Validate XML documents Are created using XML Support the Namespace Recommendation Allow validation of text elements content based on built-in or user-defined data types Allow modeling of object inheritance and type substitution Allow easy creation of complex and reusable content models

4-5 Copyright © 2004, Oracle. All rights reserved. An Example XML Schema Document The simple XML Schema uses: –A required XML Namespace string, with an xs prefix, –The element as its document root –The element to declare an element A valid XML instance document: Finance

4-6 Copyright © 2004, Oracle. All rights reserved. Validating an XML Document with an XML Schema Document In the XML instance document, use the XML namespace and reference the XML Schema using: The noNamespaceSchemaLocation attribute, or The schemaLocation attribute XSD validates noNamespaceSchemaLocation="file.xsd" schemaLocation="namespace file.xsd" <departments xmlns:xsi= " xsi:noNamespaceSchemaLocation="departments.xsd"> Finance

4-7 Copyright © 2004, Oracle. All rights reserved. Referencing an XML Schema with the schemaLocation Attribute The XML Schema defines the targetNamespace value. The XML document references the targetNamespace in the schemaLocation and the default namespace. <departments xmlns=" xmlns:xsi= " xsi:schemaLocation= " departments.xsd"> Finance <xs:schema xmlns:xs=" targetNamespace="

4-8 Copyright © 2004, Oracle. All rights reserved. Components of an XML Schema Partial component hierarchy

4-9 Copyright © 2004, Oracle. All rights reserved. Example of XML Schema Components XML document <xsd:schema xmlns:xsd=" <xsd:element name="region_id" type="xsd:int"/> <xsd:element name="region_name" type="xsd:string"/> Europe

4-10 Copyright © 2004, Oracle. All rights reserved. The Declaration Is the root element in an XML Schema document Contains: –Namespace information –Defaults –Version Example: <schema targetNamespace="URI" attributeFormDefault="qualified"|"unqualified" elementFormDefault="qualified"|"unqualified" version="version number"> <xsd:schema xmlns:xsd="

4-11 Copyright © 2004, Oracle. All rights reserved. Notes Only

4-12 Copyright © 2004, Oracle. All rights reserved. Global and Local Declarations Global declarations: –Appear as direct children of the element –Can be reused within the XML Schema document Local declarations: –Are valid in the context they are defined –Are not children of the element –Can reference global type declarations by using a namespace prefix <schema... xmlns:t="

4-13 Copyright © 2004, Oracle. All rights reserved. Notes Only

4-14 Copyright © 2004, Oracle. All rights reserved. Declaring an Element Declare a simple with: A name attribute to specify the tag name A type attribute to specify the content allowed Full syntax: <element name="name-of-element" type="global-type | built-in-type" ref="global-element-name" form="qualified | unqualified" minOccurs="non-negative number" maxOccurs="non-negative number | unbounded" default="default-value" fixed="fixed-value"> Steven

4-15 Copyright © 2004, Oracle. All rights reserved. Built-in XML Schema Data Types The XML Schema Language provides built-in data types, such as: The string type The int type The decimal type Many others ( boolean, float, and so on) Examples:

4-16 Copyright © 2004, Oracle. All rights reserved. Notes Only

4-17 Copyright © 2004, Oracle. All rights reserved. Declaring a Component The : Is a derived type extending built-in or other types Provides three primary derived types: –A Has facets (properties), such as maxInclusive

4-18 Copyright © 2004, Oracle. All rights reserved. Notes Only

4-19 Copyright © 2004, Oracle. All rights reserved. Using and SimpleTypes Declaring a : …... SKING

4-20 Copyright © 2004, Oracle. All rights reserved. Declaring Components The declaration: Must be identified by a name attribute if it is global; otherwise, it is an anonymous complex type Provides a content model that can contain: –Simple content –A declaration –A reference to a global –An declaration Can allow mixed or empty content...

4-21 Copyright © 2004, Oracle. All rights reserved. Declaring a Defines an ordered sequence of elements Must be contained within a <xsd:element name="department_id" type="xsd:int"/> <xsd:element name="department_name" type="xsd:string"/> <xsd:element name="manager_id" type="xsd:int" minOccurs="0"/> <xsd:element name="location_id" type="xsd:int" minOccurs="0"/>

4-22 Copyright © 2004, Oracle. All rights reserved. Declaring a Defines a choice of alternative elements Must also be contained within a <xsd:element name="full_time" type="xsd:string"/> <xsd:element name="part_time" type="xsd:string"/> <xsd:element name="full_name" type="xsd:string"/> <xsd:element name="contract" type="employeeType"/>

4-23 Copyright © 2004, Oracle. All rights reserved. Declaring an Empty Element Using a declaration without any elements or a content model Typically contains attributes <xsd:element name="department" maxOccurs="unbounded"/> <xsd:attribute name="department_id" type="xsd:int"/> <xsd:attribute name="department_name" type="xsd:string"/>

4-24 Copyright © 2004, Oracle. All rights reserved. Using Element Wildcards Element wildcard declarations: Allow including elements without much control Provide a way to include elements from: –Within the XML Schema and its namespace –Another namespace Are declared using : <xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>

4-25 Copyright © 2004, Oracle. All rights reserved. Declaring Attributes Declare an : Identified by the name attribute With the type attribute restricted to built-in or user-defined simple types Full syntax: <attribute name="name-of-attribute" type="global-type | built-in-type" ref="global-attribute-declaration" form="qualified | unqualified" used="optional | prohibited | required" default="default-value" fixed="fixed-value">

4-26 Copyright © 2004, Oracle. All rights reserved. Attribute Declarations: Example 1.Based on a : 2.With a default value: 3.Referencing a global type: <xsd:attribute name="department_id" type="xsd:int" default="10"/>

4-27 Copyright © 2004, Oracle. All rights reserved. Declaring and Referencing an Declare an : Identified by the name attribute Containing one or more s, or references to s Reference in a or :

4-28 Copyright © 2004, Oracle. All rights reserved. Documenting the XML Schema Document the XML Schema by using: XML comments Attributes from other namespaces An declaration: –Provides an element –Contains a element –Can be included within all other component types A big comment about this Schema

4-29 Copyright © 2004, Oracle. All rights reserved. Creating an XML Schema Document in JDeveloper Drag and drop

4-30 Copyright © 2004, Oracle. All rights reserved. Using the JDeveloper XML Schema Editor

4-31 Copyright © 2004, Oracle. All rights reserved. Using the JDeveloper XML Schema-Aware XML Editor To use the XML Schema-aware Editor features: 1.Register an XML Schema with JDeveloper 2.Associate an XML document with an XML Schema 3.Use the XML Schema-aware code-insight, and validate the XML menu features

4-32 Copyright © 2004, Oracle. All rights reserved. Registering an XML Schema with JDeveloper

4-33 Copyright © 2004, Oracle. All rights reserved. Using the XML Schema-Aware XML Editor Code-insight is invoked when a less than ( < ) character, space, or colon ( : ) is typed. Drag and drop from Component Palette

4-34 Copyright © 2004, Oracle. All rights reserved. To validate an XML document against an XML Schema: On the XML document, right-click one of the following: 1.Navigator 2.XML Editor Select Validate XML from the menu Validating an XML Document with its XML Schema in JDeveloper 1 2

4-35 Copyright © 2004, Oracle. All rights reserved. Validating an XML Document with its XML Schema by Using oraxml The oraxml Java command-line utility: Does not require registering the XML Schema Validates an XML instance document against an XML Schema specified in the schemaLocation or noNamespaceSchemaLocation attribute values Requires: –The xmlparserv2.jar in the CLASSPATH –The – schema option –The XML document file name java oracle.xml.parser.v2.oraxml -schema test.xml The input XML file is parsed without errors using schema validation mode.

4-36 Copyright © 2004, Oracle. All rights reserved. Applications for XML Schema E-commerce Web publications and syndication Enterprise Application Integration (EAI) Process control and data acquisition XSD XML Schema validates the XML information exchanged.

4-37 Copyright © 2004, Oracle. All rights reserved. XML Schema Versus DTD XML Schema: –Is more powerful and flexible than a DTD –Provides better namespace support than a DTD –Is written in XML syntax –Is extensible –Provides data type support DTD: –Provides ENTITY functionality that is not supported by XML Schema –Can be embedded in an XML document –Is written in SGML

4-38 Copyright © 2004, Oracle. All rights reserved. Converting a DTD to an XML Schema XML document: DTD: XML Schema: 120 Weiss

4-39 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Describe an XML Schema Create an XML Schema document with: –Element declarations –Attribute declarations –Custom simpleType and complexType declarations –Annotations Use the XML Schema built-in data types Associate an XML Schema with an XML instance document Validate XML documents with an XML Schema, using JDeveloper and oraxml command-line tool.

4-40 Copyright © 2004, Oracle. All rights reserved. Practice 4: Overview This practice covers the following topics: Writing an XML Schema document Creating a simple XML Schema document manually, and a valid XML instance document Modifying the XML Schema document with the XML Schema editor in JDeveloper Registering the XML Schema in JDeveloper Modifying and validating the XML document against the updated and registered XML Schema

4-41 Copyright © 2004, Oracle. All rights reserved. Full Notes Page

4-42 Copyright © 2004, Oracle. All rights reserved. Full Notes Page

4-43 Copyright © 2004, Oracle. All rights reserved. Full Notes Page

4-44 Copyright © 2004, Oracle. All rights reserved.