Top Banner

Click here to load reader

XML Schema Infoset Model, Part 1 - Eclipse

Jan 02, 2017

ReportDownload

Documents

dangtuyen

  • XML Schema Infoset Model, Part 1

    Presented by developerWorks, your source for great tutorials

    ibm.com/developerWorks

    Table of ContentsIf you're viewing this document online, you can click any of the topics below to link directly to that section.

    1. Before you start......................................................... 22. XML Schema fundamentals .......................................... 33. Setting up the development environment .......................... 54. Using XML Schema Infoset Model classes ........................ 95. Working with XML Schema resources in Eclipse ................. 216. Working with namespaces............................................ 257. You try it!................................................................. 278. Summary and resources .............................................. 28

    XML Schema Infoset Model, Part 1 Page 1 of 29

  • Section 1. Before you start

    About this tutorialThe first of a two-part series, this tutorial gives you the building blocks you need to set up andwork with the XML Schema Infoset Model. In this tutorial, you will learn: How to set up the development environment How to use the XML Schema Infoset Model classes How to load and create XML Schema models How to link XML Schema models together

    This tutorial is for developers who are familiar with Java, XML, and XML Schema, and who areinterested in combining these technologies using the XML Schema Infoset Model. You shouldtherefore understand how to write Java code and understand how XML Schemas work. Someunderstanding of the Unified Modeling Language (UML) is helpful but not required. You canget an introduction to XML Schema fundamentals in the Resources on page 28 at the end of thistutorial, and an introduction to UML basics in How to read UML class diagrams on page 9 .

    About the authorDave Spriet is a software developer for the IBM Toronto Laboratory. He develops tools for theWebSphere Business Integration Message Broker (WBIMB) product. He specializes inobject-oriented technologies, XML, XML Schema, middleware, and UML Modeling. He is alsoa committer for the XML Schema Infoset Model component. Dave has a Bachelor of Sciencedegree (Honors) in Computer Science and Statistics from McMaster University. He welcomesany comments; please direct them to [email protected]

    ibm.com/developerWorks Presented by developerWorks, your source for great tutorials

    Page 2 of 29 XML Schema Infoset Model, Part 1

    http://www.eclipse.org/xsdhttp://www.eclipse.org/xsdhttp://www.eclipse.org/xsdhttp://www.eclipse.org/xsdmailto:[email protected]

  • Section 2. XML Schema fundamentals

    What is an XML schema?An XML schema, like a DTD (Document Type Definition), defines the legal building blocks ofan XML document. More and more companies are starting to use XML schemas to describetheir documents shared between business partners because of a schema's wide range offeatures: Schemas define elements that can appear in a document Schemas define attributes that can appear in a document Schemas define which elements are child elements Schemas define the order of child elements Schemas define the number of child elements Schemas define whether an element is empty or can include text Schemas define data types for elements and attributes Schemas define default and fixed values for elements and attributes

    So, are XML schemas the successors of DTDs? I think they will be soon, for the followingreasons: Schemas are extensible to future additions Schemas are richer and more useful than DTDs Schemas are written in XML Schemas support data types Schemas support namespaces

    Several XML Schema proposals exist, but the XML Schema Infoset Model is 100% compatiblewith the W3C XML Schema recommendation V 1.0, 2 May 2001. This version is described in:XML Schema Part 0: Primer, XML Schema Part 1: Structures, and XML Schema Part 2:Datatypes.

    What is the XML Schema Infoset Model?The XML Schema Infoset Model is a library for use with any code that examines, creates, ormodifies XML Schemas. These XML Schemas can be stand-alone schemas or part of otherartifacts, such as XForms or WSDL documents. The library provides an API for manipulatingthe components of an XML Schema as described by the W3C XML Schema specifications, aswell as an API for manipulating the DOM-accessible representation of XML Schema as aseries of XML documents, and for keeping these representations in agreement as schemasare modified.

    This library includes APIs to serialize and deserialize XML Schema documents, and to do

    Presented by developerWorks, your source for great tutorials ibm.com/developerWorks

    XML Schema Infoset Model, Part 1 Page 3 of 29

    http://www.eclipse.org/xsdhttp://www.eclipse.org/xsdhttp://www.eclipse.org/xsdhttp://www.eclipse.org/xsdhttp://www.w3.org/TR/xmlschema-0/http://www.w3.org/TR/xmlschema-0/http://www.w3.org/TR/xmlschema-0/http://www.w3.org/TR/xmlschema-0/http://www.w3.org/TR/xmlschema-0/http://www.w3.org/TR/xmlschema-1/http://www.w3.org/TR/xmlschema-1/http://www.w3.org/TR/xmlschema-1/http://www.w3.org/TR/xmlschema-1/http://www.w3.org/TR/xmlschema-1/http://www.w3.org/TR/xmlschema-2/http://www.w3.org/TR/xmlschema-2/http://www.w3.org/TR/xmlschema-2/http://www.w3.org/TR/xmlschema-2/http://www.w3.org/TR/xmlschema-2/

  • integrity checking of XML Schemas. This integrity checking looks for things like elementreferences that reference non-existent global elements invalid maximum values.

    ibm.com/developerWorks Presented by developerWorks, your source for great tutorials

    Page 4 of 29 XML Schema Infoset Model, Part 1

  • Section 3. Setting up the development environment

    Setup overviewFirst familiarize yourself with the Eclipse environment. The main areas to focus on are: The Workbench The Workspace Perspectives usage Eclipse plug-ins Team support

    Now we'll download and install the Eclipse Modeling Framework and the XML Schemacomponents, and verify the installation.

    Downloading and installing the EMF and XML Schemacomponents

    1. Java Runtime Environment V 1.3. Eclipse does not include a Java Runtime Environment(JRE), so you will need a 1.3-level Java runtime or Java Development Kit (JDK) installed onyour machine in order to run Eclipse. I recommend using the IBM or the Sun JRE/JDK: IBM developer kit (http://www.ibm.com/developerworks/java/jdk/) Sun developer kit (http://java.sun.com/j2se/1.3/download.html)

    2. Eclipse Base V2.1.1. After you read and understand the Eclipse.org Software UserAgreement, then download the Eclipse base. For this tutorial, we are using the latestrelease, which is 2.1.1 at the time of writing, but almost any version will do. Download andunzip a copy of the Eclipse base V2.1.1.. Throughout this document we will refer to%ECLIPSE_BASE%, which is the base directory in which you unzipped the Eclipse baseV2.1.1.

    3. Eclipse Modeling Framework, V1.1.0, Build 20030620_1105VL. Next, download theEclipse Modeling Framework component, which we will call EMF throughout this tutorial. Forthis tutorial, we are using version 1.1.0, Build 20030620_1105VL. You can either downloadEMF from the EMF Web site or directly download EMF Version 1.1.0 from the followinglinks: EMF Runtime EMF Documentation EMF SourceAfter you have downloaded EMF V1.1.0, you should unzip the three zip files into the%ECLIPSE_BASE%\eclipse directory. Make sure that the directories line up so that theEMF plug-ins go into the %ECLIPSE_BASE%\eclipse\plugins directory.

    Presented by developerWorks, your source for great tutorials ibm.com/developerWorks

    XML Schema Infoset Model, Part 1 Page 5 of 29

    http://www.eclipse.orghttp://www.ibm.com/developerworks/java/jdk/http://www.ibm.com/developerworks/java/jdk/http://www.ibm.com/developerworks/java/jdk/http://java.sun.com/j2se/1.3/download.htmlhttp://java.sun.com/j2se/1.3/download.htmlhttp://java.sun.com/j2se/1.3/download.htmlhttp://www.eclipse.org/legal/notice.htmlhttp://www.eclipse.org/legal/notice.htmlhttp://www.eclipse.org/legal/notice.htmlhttp://www.eclipse.org/legal/notice.htmlhttp://download.eclipse.org/downloads/index.phphttp://download.eclipse.org/downloads/index.phphttp://download.eclipse.org/downloads/index.phphttp://www.eclipse.org/emf/http://download.eclipse.org/tools/downloads/emf/emf_1.1.0_20030620_1105VL.ziphttp://download.eclipse.org/tools/downloads/emf/emf_1.1.0_20030620_1105VL.ziphttp://download.eclipse.org/tools/downloads/emf/emf.doc_1.1.0_20030620_1105VL.ziphttp://download.eclipse.org/tools/downloads/emf/emf.doc_1.1.0_20030620_1105VL.ziphttp://download.eclipse.org/tools/downloads/emf/emf.source_1.1.0_20030620_1105VL.ziphttp://download.eclipse.org/tools/downloads/emf/emf.source_1.1.0_20030620_1105VL.zip

  • As an alternative, you can keep these additional components separated from the base byunzipping the three zip files into a subdirectory and then using an Eclipse link file to point towhere the additional plug-ins are. Remember that EMF and XML Schema components arejust Eclipse plug-ins; they work the same way as any other plug-ins in Eclipse. To keepthese other plug-ins separated from the base, you need to create a "links" directory directlyunder the %ECLIPSE_BASE%\eclipse directory. In the links directory, add a file thatcontains the following: Filename: org.eclipse.emf.link Contents: path=C:\\Dev\\eclipse\\emf110

    NOTE: Remember that on windows you have to escape the backslashes in this file.

    4. XML Schema Infoset Model, V1.1.0, Build 20030620_1105VL. Next, download the XMLSchema Infoset component, which we will call XML Schema model throughout this tutorial.For this tutorial, we are using version 1.1.0, Build 20030620_1105VL. You can downloadXML Schema model from the XML Schema Infoset Model Web site or you can directlydownload XML Schema model Version 1.1.0 from the following links: XSD Ru

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.