Copyright 2003-04 John Cowan under the GNU GPL1 RELAX NG: DTDs ON WARP DRIVE John Cowan Reuters.

Slides:



Advertisements
Similar presentations
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.
Advertisements

17 Apr 2002 XML Syntax: DTDs Andy Clark. Validation of XML Documents XML documents must be well-formed XML documents may be valid – Validation verifies.
Managing XML and Semistructured Data Lecture 12: XML Schema Prof. Dan Suciu Spring 2001.
ISO DSDL ISO – Document Schema Definition Languages (DSDL) Martin Bryan Convenor, JTC1/SC18 WG1.
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.
XML 6.3 DTD 6. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:  Elements.
Document Type Definitions
13-Jun-15 RELAX NG. 2 Caveat I did not have a RELAX NG validator when I wrote these slides. Therefore, if an example appears to be wrong, it probably.
CSE 636 Data Integration XML Schema. 2 XML Schemas W3C Recommendation: Generalizes DTDs Uses XML syntax Two documents: structure.
15-Jun-15 RELAX NG. 2 What is RELAX NG? RELAX NG is a schema language for XML It is an alternative to DTDs and XML Schemas It is based on earlier schema.
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
Lecture 14 XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name.
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
RELAX NG. Caveat I did not have a RELAX NG validator when I wrote these slides. Therefore, if an example appears to be wrong, it probably is.
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.
XML Schemas and Namespaces Lecture 11, 07/10/02. BookStore.dtd.
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.
XML Verification Well-formed XML document  conforms to basic XML syntax  contains only built-in character entities Validated XML document  conforms.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Copyright John Cowan under the GNU GPL1 Describing Document Types: The Schema Languages of XML Part 1 John Cowan.
Introduction to XML This material is based heavily on the tutorial by the same name at
**1 RELAX NG: DTDs ON WARP DRIVE John Cowan Reuters Health Information.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
XML Validation I DTDs Robin Burke ECT 360 Winter 2004.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
Lecture 15 XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
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.
Dr. Azeddine Chikh IS446: Internet Software Development.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
XML and Web Services CS409 Application Services Even Semester 2007.
New Perspectives on XML, 2nd Edition
An OO schema language for XML SOX W3C Note 30 July 1999.
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.
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.
XML Validation II Schemas Robin Burke ECT 360. Outline Namespaces Documents  Data types XML Schemas Elements Attributes Derived data types RELAX NG.
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)
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Copyright 2004 John Cowan 1 Infinite Diversity in Infinite Combinations why one schema language is not enough John Cowan.
Document Type Definition (DTD) Eugenia Fernandez IUPUI.
XML Validation II Advanced DTDs + Schemas Robin Burke ECT 360.
Lecture 0 W3C XML Schema. Topics Status Motivation Simple type vs. complex type.
XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name value pair;
Copyright John Cowan under the GNU GPL1 Describing Document Types: The Schema Languages of XML Part 2 John Cowan.
Using DSDL plus annotations for Netconf (+) data modeling Rohan Mahy draft-mahy-canmod-dsdl-01.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
Infinite Diversity in Infinite Combinations
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Describing Document Types: The Schema Languages of XML Part 1
THE DATATYPES OF XML SCHEMA A Practical Introduction
Presentation transcript:

Copyright John Cowan under the GNU GPL1 RELAX NG: DTDs ON WARP DRIVE John Cowan Reuters

Copyright John Cowan under the GNU GPL2 Copyright Copyright © John Cowan Licensed under the GNU General Public License ABSOLUTELY NO WARRANTIES; USE AT YOUR OWN RISK Portions written by James Clark; used by permission Black and white for readability The Gentium font available at

Copyright John Cowan under the GNU GPL3 Abstract In this tutorial you will learn how to use the RELAX NG schema language, an alternative schema language for XML. RELAX NG allows easy and intuitive descriptions of just what is and what is not allowed in an XML document. It is simple enough to learn in a few hours, and rich and flexible enough to support the design and validation of every kind of document from the very simple to the very complex. Once RELAX NG's concepts have crossed the blood-brain barrier, you will never be able to take any other schema language very seriously again.

Copyright John Cowan under the GNU GPL4 Roadmap RELAX NG goals (21 slides) The invoice example (9 slides) Patterns (22 slides) Namespace Routing Language (4 slides) Datatypes (12 slides) The XLink example (12 slides) Tools (14 slides) XSD datatypes (16 slides)

Copyright John Cowan under the GNU GPL5 RELAX NG GOALS

Copyright John Cowan under the GNU GPL6 DTDs On Warp Drive An evolution/generalization of DTDs Shares the same basic paradigm Based on experience with SGML, XML Adds and subtracts features from DTDs DTDs can be automatically converted

Copyright John Cowan under the GNU GPL7 Reusable Knowledge Experts in designing SGML and XML DTDs will find their skills transfer easily Design patterns commonly used in XML DTDs can be reused Much more mature than if based on a completely new and different paradigm Higher degree of confidence in its design is possible

Copyright John Cowan under the GNU GPL8 Easy To Learn And Use Allows schemas to be patterned after the structure of the documents they describe Allows definitions to be composed from other definitions in a variety of ways Treats attributes and elements as uniformly as possible

Copyright John Cowan under the GNU GPL9 Namespaces DTDs are namespace-blind RELAX NG fully supports namespaces for elements and attributes Namespace support is purely syntactic, not tied to one schema per namespace Name classes support “any name” and “any name in specified namespace”

Copyright John Cowan under the GNU GPL10 Datatyping Supports pluggable simple datatype libraries Basic library supports strings and tokens Full XML Schema Part 2 datatypes available (including facets) New libraries can be readily designed and built as needed.

Copyright John Cowan under the GNU GPL11 Composability Schema languages provide atomic objects (elements, attributes, text, typed data) and methods of composing them (sequence, repetition, choice) All RELAX NG atomic objects can be composed with any available method Improves ease of learning, use, power; decreases complexity

Copyright John Cowan under the GNU GPL12 Closure RELAX NG is closed under union –If two schemas exist describing two document types, then a schema describing the union of the two document types is trivial to create –Consequently, the content model of an element can be context-dependent

Copyright John Cowan under the GNU GPL13 Two Syntaxes, One Language Provides two interconvertible syntaxes: –an XML one for processing –a compact non-XML one for human authoring We will learn the compact syntax One example of the XML syntax is provided to assist in learning it

Copyright John Cowan under the GNU GPL14 Attributes “Elements or attributes?” –Reasonable people can differ –Attributes are treated as much like elements as possible Content models include elements as well as attributes Attribute defaulting is not done

Copyright John Cowan under the GNU GPL15 Non-goal: Attribute Defaulting Attribute defaulting can only be done by DTDs or W3C XML Schema when the value does not depend on context Sensible attribute defaults often depend on context (inheritance of xml:lang, e.g.) Attribute defaulting is trivial for transformation languages such as XSLT

Copyright John Cowan under the GNU GPL16 Non-goal: PSVI RELAX NG has no post-validation infoset enhancement Infoset enhancement can be done as a separate layer Sun’s Multi-Schema Validator provides datatype information Separation of concerns promotes efficiency, flexibility

Copyright John Cowan under the GNU GPL17 Annotations Annotations in the form of elements and attributes can be interspersed in RELAX NG schemas for various purposes: –DTD-style attribute defaults –documentation –embedded Java code Conforming RELAX NG validators ignore annotations

Copyright John Cowan under the GNU GPL18 Mixed Content SGML had problems with complex mixed-content models XML DTDs tightly restrict mixed-content models RELAX NG allows character content mixed with any content model

Copyright John Cowan under the GNU GPL19 Unordered Content SGML’s & operator allows unordered content models –A & B means ((A, B) | (B, A)) XML DTDs removed & to reduce implementation complexity RELAX NG restores & with improvements

Copyright John Cowan under the GNU GPL20 Customization Definitions included from another schema can be overridden Multiple definitions from the same or different schemas can be intelligently combined –as if with | –as if with &

Copyright John Cowan under the GNU GPL21 A Real Standard Being standardized in OASIS by the RELAX NG Technical Committee A major component of ISO DSDL, the new Document Schema Definition Languages umbrella-standard

Copyright John Cowan under the GNU GPL22 Non-goal: Inheritance Inheritance-based schemas only model single inheritance Modeling often requires multiple inheritance (at least for interfaces) Schema languages are about syntactic details, not about models

Copyright John Cowan under the GNU GPL23 Non-goal: Identity Constraints Identity constraints are not supported Identity constraints are still a developing research area Different applications have different requirements from simple to complex Some RELAX NG tools support DTD- style semantics for ID, IDREF(S)

Copyright John Cowan under the GNU GPL24 Non-goal: Schema Binding There is no standard way for a document to specify “its schema” Receivers often want to verify against agreed- on schemas, not sender-specified ones Documents may be validated against different schemas for different purposes The validation model takes two inputs: a document and a schema Just part of the XML processing issue

Copyright John Cowan under the GNU GPL25 Interoperability You can convert a DTD to RELAX NG, preserving modularity You can author in RELAX NG and deliver in DTD or W3C XML Schema or both RELAX NG allows embedded Schematron rules

Copyright John Cowan under the GNU GPL26 Pronunciation "Relaxing" is the standard way Some people say "relax en gee"

Copyright John Cowan under the GNU GPL27 AND NOW TO RELAX!

Copyright John Cowan under the GNU GPL28

Copyright John Cowan under the GNU GPL29 THE INVOICE EXAMPLE

Copyright John Cowan under the GNU GPL30 An Invoice in XML Reuters Health Information 45 West 36th St. New York NY Reuters Health Information 45 West 36th St. New York NY Net 10 days Binder, D-ring, 1.5" Fork, Plastic, Heavy, Medium

Copyright John Cowan under the GNU GPL31 The Invoice Schema (1) element invoice { attribute number { text }, attribute date { text }, element soldTo { element name { text }, element address { text } }, element shipTo { element name { text }, element address { text } },

Copyright John Cowan under the GNU GPL32 The Invoice Schema (2) element terms { text }, element item { attribute unitPrice { text }, attribute ordered { text }, attribute shipped { text }, attribute backOrdered { text }?, text }* }

Copyright John Cowan under the GNU GPL33 The XML format

Copyright John Cowan under the GNU GPL34 Things To Note The structure of the schema parallels the structure of the document Element content models include attributes as well as child elements The optional attribute is marked with ? "text" is the equivalent of #PCDATA or CDATA

Copyright John Cowan under the GNU GPL35 Things To Note Commas separate multiple components of a content model when the components appear in the given order Of course, the order of attributes does not matter! Consequently, attributes can appear in the schema before, after, or mixed in with child elements

Copyright John Cowan under the GNU GPL36 Definition Form start = element invoice { attribute number { text }, attribute date { text }, element soldTo { name-addr }, element shipTo { name-addr }, element terms { text } element item { attribute ordered { text }, attribute shipped { text }, attribute backOrdered { text }?, attribute unitPrice, text}* } } name-addr = element name { text }, element address { text }

Copyright John Cowan under the GNU GPL37 Definition Form Notes In definition form, there must always be a definition of start You refer to a rule using just its name The order of the rules does not matter; use whatever order makes sense to you (top-down, bottom-up, alphabetical) Rule names are only relevant to the schema, and never appear in the document instance

Copyright John Cowan under the GNU GPL38 DTD-Style Definitions start = element invoice { attribute number { text }, attribute date { text }, soldTo, shipTo, terms, item } soldTo = element soldTo { name-addr } shipTo = element shipTo { name-addr } terms = element terms { text } item = element item {... } name-addr = name, address name = element name { text } address = element address { text }

Copyright John Cowan under the GNU GPL39 PATTERNS

Copyright John Cowan under the GNU GPL40 Patterns Patterns are the basic building blocks of RELAX NG schemas and rules Some kinds of patterns can contain sub- patterns enclosed in braces ( { … } )

Copyright John Cowan under the GNU GPL41 Element Patterns The form is: element name { … } The content model (child elements and attributes) is contained within the braces Content models consist of one or more patterns

Copyright John Cowan under the GNU GPL42 Attribute Patterns The form is: attribute name { … } The content model is contained within the braces Content models consist of one or more patterns You can't have child elements or attributes within attributes, of course!

Copyright John Cowan under the GNU GPL43 Attribute Patterns So what patterns can be inside attributes? –The text pattern - equivalent to CDATA –Datatypes (next section) –Literal strings in quotes: attribute country { "US" } means the country attribute must have the value US.

Copyright John Cowan under the GNU GPL44 Element Patterns So what patterns can be inside elements? –The text pattern - equivalent to #PCDATA –Datatypes (next section) –Literal strings in quotes: element country { "US" } means the country element must have the content US.

Copyright John Cowan under the GNU GPL45 The Text Pattern Matches any amount of arbitrary text, possibly broken up by child elements Equivalent to #PCDATA in elements or CDATA in attributes text*, text?, text+ all mean the same as text

Copyright John Cowan under the GNU GPL46 Namespaces To declare elements and attributes in namespaces, use QNames in element and attribute patterns Namespace prefixes are declared like this: namespace foo = " (some URI) " Namespace declarations must come first in the schema

Copyright John Cowan under the GNU GPL47 Default Namespaces You can declare a namespace for unprefixed elements (not attributes) like this: default namespace = " (some URI) " If you want the default namespace to have a prefix too, use: default namespace foo = "( some URI) "

Copyright John Cowan under the GNU GPL48 Namespaces Here's an example: namespace one = " namespace two = " default namespace = " element para { attribute one:class { text }, attribute two:class { text }, element line { text }* }

Copyright John Cowan under the GNU GPL49 Choice Two patterns separated by | represent a choice between them; the document can match one pattern or the other, not both Arbitrary patterns are allowed in a choice: you can have a choice between attributes, between elements, or even between an element and an attribute!

Copyright John Cowan under the GNU GPL50 Choice A useful case: element data { (element id { text } | attribute id { text }), text } You cannot mix, and | in one list; use parentheses to disambiguate

Copyright John Cowan under the GNU GPL51 Choice Enumerated values use choice like this: element font { attribute size { "10" | "12" | "14" | "16" } }

Copyright John Cowan under the GNU GPL52 Interleave Interleave is a cross between choice and sequence When patterns are combined with &, they all must appear but it can be in any order (as in SGML) … … or even mixed together!

Copyright John Cowan under the GNU GPL53 Interleave So this schema... element head { element meta { empty }* & element title { text } } … matches a head element that has any number of meta child elements (including zero) and a required title child element mixed in anywhere.

Copyright John Cowan under the GNU GPL54 Interleave Note: In the case of attributes, sequence and interleave are the same thing, because attributes don't have ordering So you can use either, or & according to what is the most convenient

Copyright John Cowan under the GNU GPL55 Quantifiers You can place an *, ?, or + after any pattern to allow it to be repeated: – * means zero or more times – ? means zero or one times – + means one or more times These mean the same as in DTD content models, but can be used after any pattern, not just rule names

Copyright John Cowan under the GNU GPL56 ANY? There is no built-in ANY content model, corresponding to empty for empty content models or notAllowed for forbidden models Here’s how it can be done: ANY = element * { attribute * {text}* & text & ANY* }

Copyright John Cowan under the GNU GPL57 Multiple Schemas external incorporates one pattern document into another include incorporates one set of rules into another, and allows for overriding any of the included rules by name Rules with identical names can also be combined by choice or by interleave

Copyright John Cowan under the GNU GPL58 Context Sensitivity The first paragraph cannot have footnotes; the remainder can: start = element doc {first, other*} first = element para { text } other = element para { mixed { element footnote {text}*} }

Copyright John Cowan under the GNU GPL59 Restrictions on Schemas The obvious XML ones: no elements or attributes within attributes, only one top- level element, etc. etc. Attributes can't have conflicting definitions in a single element Wildcard attributes must use * or + Lists of lists and lists of text don't work

Copyright John Cowan under the GNU GPL60 Restrictions on Schemas Elements can't group or interleave simple content (data, value, or list) with complex content (child elements and/or text) Interleave doesn't allow an element with a given name to be used in more than one subpattern Interleave doesn't allow text in more than one subpattern

Copyright John Cowan under the GNU GPL61 Comments Ordinary comments begin with # Documentation comments begin with ## and are copied (in groups) into the XML syntax as a:documentation elements The a: prefix represents the namespace of the DTD Compatibility extension to RELAX NG

Copyright John Cowan under the GNU GPL62 NAMESPACE ROUTING LANGUAGE

Copyright John Cowan under the GNU GPL63 What it is Not a standard yet, but some version of it will become one An NRL schema specifies how to apply multiple subschemas to different parts of a document Basically it's a map between namespace names and schema URIs

Copyright John Cowan under the GNU GPL64 How it works The document is carved up into subtrees whose elements have a common namespace name The subschema associated with that name is used to validate the subtree Subschemas can be in any schema language including XML Schema and even DTD

Copyright John Cowan under the GNU GPL65 Concurrent validation Multiple schemas can be applied to a subtree to cause concurrent validation Example: XHTML validation with RELAX NG requires a check that no a element has another a element as its ancestor A small schema that must fail validation can be used to enforce this limtation

Copyright John Cowan under the GNU GPL66 Other features A subordinate namespace can be attached to a superior namespace so that they will be validated together by the superior namespace's schema Attribute-only schemas can be supported using a dummy element name Validation can begin at a specific element specified by a simple form of XPath

Copyright John Cowan under the GNU GPL67 DATATYPES

Copyright John Cowan under the GNU GPL68 Datatypes A type is a named set of values An datatype provides a standardized, machine-checkable representation of a type

Copyright John Cowan under the GNU GPL69 Schema Datatypes DTDs have only a few datatypes for attributes and only one datatype for elements XML Schema provides a long, but fixed, list of datatypes RELAX NG can work with any datatype library, including the XSD (XML Schema Datatypes) library

Copyright John Cowan under the GNU GPL70 RELAX NG Datatypes Datatype patterns are written using QNames This use of QNames can't be confused with QNames for elements or attributes, because those are only recognized after the words element and attribute The built-in datatypes string and token don’t have prefixes and are recognized by all implementations

Copyright John Cowan under the GNU GPL71 Declaring Datatype Libraries A prefix is declared like this: datatypes lib = " (some URI) " Datatype library declarations must come first RELAX NG processors recognize a system-dependent list of datatype library URIs

Copyright John Cowan under the GNU GPL72 Useful Datatypes The xsd prefix is predeclared for XML Schema Datatypes xsd:integer represents an integer of arbitrary length xsd:ID, IDREF, and IDREFS are the same as the corresponding DTD types We'll discuss all the xsd types later.

Copyright John Cowan under the GNU GPL73 Typed Values "0" and token "0" match a “0” character with possible surrounding whitespace string "0" matches a “0” character exactly xsd:integer "0" matches “0” or “00” or “000” or “-0” or...

Copyright John Cowan under the GNU GPL74 Mixing Datatypes Datatypes can't be mixed with anything in the same content model, as in: element foo {## ERROR! xsd:int, xsd:ID, element bar { empty } } Character content that represents a datatype cannot have any siblings

Copyright John Cowan under the GNU GPL75 Mixing Datatypes Choices involving datatypes are fine: element foo { xsd:int | xsd: Name } element bar { xsd:int | element baz { text } }

Copyright John Cowan under the GNU GPL76 Datatype Exceptions xsd:nonNegativeInteger and xsd:nonPositiveInteger are existing types How do we say “non-zero integer”? xsd:integer - xsd:integer "0" We can likewise express a token that is not a name: xsd:token - xsd:Name

Copyright John Cowan under the GNU GPL77 Parameters Parameters restrict the values of datatypes Each datatype has specific parameters are legal with it An integer between 0 and 999 inclusive: xsd:integer { minInclusive = "0" maxInclusive = "999" }

Copyright John Cowan under the GNU GPL78 Lists List patterns specify that character content or an attribute value is to be separated by whitespace into tokens The pattern list {xsd:integer*} matches a list of zero or more white- space-separated integers This example needs * because list itself does not imply repetition

Copyright John Cowan under the GNU GPL79 Lists The pattern list {(xsd:integer, token)+} matches the string " 32 foo 45 bar 76 baz"

Copyright John Cowan under the GNU GPL80 THE XLINK EXAMPLE

Copyright John Cowan under the GNU GPL81 XLink A W3C Recommendation for general hyperlinking in XML documents Simple links are like HTML a or img elements Extended links specify multiple endpoints, roles, and traversal paths XLink is all done by attributes: any element can function in any role

Copyright John Cowan under the GNU GPL82 The XLink Namespace namespace xlink = "

Copyright John Cowan under the GNU GPL83 XLink Attribute Rules href = attribute xlink:href {xsd:anyURI} role = attribute xlink:role {xsd:anyURI} arcrole = attribute xlink:arcrole {xsd:anyURI} title.att = attribute xlink:title {text} label = attribute xlink:label {xsd:NCName} from = attribute xlink:from {xsd: NCName} to = attribute xlink:to {xsd: NCName}

Copyright John Cowan under the GNU GPL84 XLink Attribute Rules show = attribute xlink:show {"new"|"replace"|"embed"|"other"| "none"} actuate = attribute xlink:actuate {"onLoad"|"onRequest"|"other"| "none"}

Copyright John Cowan under the GNU GPL85 Simple Links simple = element * { attribute xlink:type {"simple"}, ref?, role?, arcrole?, title.att?, show?, actuate?, anyAttr*, (anyElem | text)* }

Copyright John Cowan under the GNU GPL86 Extended Links extended = element * { attribute xlink:type {"extended"}, role?, title.att?, anyAttr*, (title | resource | locator | arc | anyElem | text)* }

Copyright John Cowan under the GNU GPL87 Title Elements Description of link or endpoint: title = element * { attribute xlink:type {"title"}, anyAttr*, (anyElem | text)* }

Copyright John Cowan under the GNU GPL88 Resource Elements Local endpoints of an extended link: resource = element * { attribute xlink:type {"resource"}, role?, title.att?, label?, anyAttr*, (anyElem | text)* }

Copyright John Cowan under the GNU GPL89 Locator Elements Remote endpoints of an extended link: locator = element * { attribute xlink:type {"locator"}, href, role?, title.att?, label?, anyAttr*,(title | anyElem | text)* }

Copyright John Cowan under the GNU GPL90 Arc Elements Traversal paths through an extended link: arc = element * { attribute xlink:type {"arc"}, arcrole?, title.att?, show?, actuate?, from?, to?, anyAttr*, (title | anyElem | text)* }

Copyright John Cowan under the GNU GPL91 Non-XLink Elements and Attributes anyElem = element * { anyAttr*, (anyElem | text)* } anyAttr = attribute * - xlink:* {text}

Copyright John Cowan under the GNU GPL92 The Whole Document start = element * { anyAttr*, (simple | extended | anyElem)* }

Copyright John Cowan under the GNU GPL93 TOOLS

Copyright John Cowan under the GNU GPL94 The Jing validator Written by James Clark, principal author of RELAX NG Java based command-line tool –Validates schemas –Validates documents against schemas Accepts either compact or XML syntax Optionally enforces DTD ID/IDREF

Copyright John Cowan under the GNU GPL95 The Jing validator Also usable as a validation library within a Java program Provides JAXP (Sun-standard) interface Provides native interface Validates against other schema languages: –W3C XML Schema –Schematron –Namespace Routing Language (meta)

Copyright John Cowan under the GNU GPL96 The Trang translator Another James Clark product Translates schemas: –Input: XML syntax, compact syntax, DTDs –Output: XML syntax, compact syntax, DTDs, W3C XML Schema Output schemas may be looser than the input schema (accept a superset of what the input accepts)

Copyright John Cowan under the GNU GPL97 Sun RELAX NG translator Translates other schema languages into XML syntax: –DTDs –RELAX Core/Namespace –TREX (predecessor of RELAX NG) –Subset of XML Schema Does not preserve schema structure

Copyright John Cowan under the GNU GPL98 Instance to schema InstanceToSchema generates a RELAX NG schema from one or more XML instances Examplotron ( is a schema language that resembles an instance with optional annotations and is translated into RELAX NG

Copyright John Cowan under the GNU GPL99 Sun Multi-Schema Validator By Kohsuke KAWAGUCHI, a major RELAX NG contributor Validates documents (command-line or library) using any schema language supported by the Sun RELAX NG Translator Also handles stand-alone or embedded Schematron rules

Copyright John Cowan under the GNU GPL100 Validation in.NET Tenuto is a C# implementation of validation for the Common Language Runtime environment Supports XML syntax, XSD library Does not support ID/IDREF semantics RelaxngValidatingReader is an unrelated implementation of XMLReader that validates input against a RELAX NG schema

Copyright John Cowan under the GNU GPL101 The Bali validator generator Accepts a RELAX NG schema and generates special-purpose code to validate documents against that particular schema The generated validator is faster and smaller than a general-purpose validator Generates Java, C++, or C#

Copyright John Cowan under the GNU GPL102 The VBRELAXNG validator A validator for the XML syntax written in Visual Basic 6.0 Provides validation as an ActiveX control Requires MSXML 4.0 parser Topologi Schematron Validator uses this control

Copyright John Cowan under the GNU GPL103 The RelaxNGCC compiler Accepts a subset of RELAX NG (no ambiguous grammars) with annotations; RelaxMeter tool checks for ambiguities Compiles specified RELAX NG rules into Java classes Embedded Java code can refer to the values matched by datatype, text, and list patterns Analogous to JavaCC

Copyright John Cowan under the GNU GPL104 The RelaxNGCC compiler The generated code requires a source of SAX events (typically a parser) Objects of the generated classes are data bindings for RELAX NG rules considered as types The killer app for RELAX NG?

Copyright John Cowan under the GNU GPL105 The RELAXER compiler Generates Java objects from RELAX NG schemas without embedded code Imposes slightly different restrictions on schemas (weaker if DOM available) Provides serialization from Java as well as parsing to Java Analogous to JAXB The killer app for RELAX NG?

Copyright John Cowan under the GNU GPL106 Editors oXygen and Topologi editors validate against RELAX NG schemas xmloperator and an Emacs mode allow editing guided by a RELAX NG schema Vim syntax coloring for writing schemas in the compact syntax

Copyright John Cowan under the GNU GPL107 The libxml2 library Provides parsing and (RELAX NG) validation services for C programs Packaged with xmllint, an XML parser and RELAX NG validator Part of the GNOME desktop, but available separately

Copyright John Cowan under the GNU GPL108 XSD DATATYPES

Copyright John Cowan under the GNU GPL109 Mini-roadmap Types (11 slides) Facets (5 slides)

Copyright John Cowan under the GNU GPL110 XML Schema Datatypes A type is a named set of values An XML Schema datatype provides a standardized, machine-checkable representation of a type XML Schema types can be grouped: –numeric, date, boolean, string, misc.

Copyright John Cowan under the GNU GPL111 Numeric Types Decimal types Floating-point types

Copyright John Cowan under the GNU GPL112 Decimal Types decimal –integer nonPositiveInteger –negativeInteger nonNegativeInteger –positiveInteger –unsigned{Long, Int, Short, Byte} long, int, short, byte

Copyright John Cowan under the GNU GPL113 Decimal Types long, short, int, and byte are the same as in Java: 64, 32, 16, 8 bits unsignedLong, unsignedShort, unsignedInt, and unsignedByte are the obvious unsigned analogues All other numeric types are unbounded

Copyright John Cowan under the GNU GPL114 Floating-point Types Only two floating-point types –float –double IEEE ranges (same as Java, all modern hardware)

Copyright John Cowan under the GNU GPL115 Date Types duration date, time, dateTime gYear, gMonth, gDay, gYearMonth, gMonthDay

Copyright John Cowan under the GNU GPL116 Date Types Duration –duration Single Time Interval –dateTime, date, gYear, gYearMonth Recurring Time Interval –time, gMonth, gDay, gMonthDay

Copyright John Cowan under the GNU GPL117 Date Type Examples

Copyright John Cowan under the GNU GPL118 Boolean Type Only two values are legal: – true (which can also be written 1 ) – false (which can also be written 0 )

Copyright John Cowan under the GNU GPL119 String Types string –normalizedString token –language –NMTOKEN(S) –Name »NCName o ID, IDREF(S), ENTITY(IES)

Copyright John Cowan under the GNU GPL120 Miscellaneous Types Raw octet types –hexBinary –base64Binary anyURI QName NOTATION

Copyright John Cowan under the GNU GPL121 Facets Allow the creation of new datatypes by restricting the existing ones in one or more ways Called params in RELAX NG Facets can be grouped into families applicable to datatype families: –length, value, pattern –enumeration, whiteSpace

Copyright John Cowan under the GNU GPL122 Length Facets Applicable to string and miscellaneous types length facet gives exact length minLength and maxLength facets set limits; either or both may be used lengths of hexBinary and base64Binary types are measured in octets, not characters

Copyright John Cowan under the GNU GPL123 Value Facets Applicable to numeric and date types minExclusive and minInclusive specify a lower bound; either but not both may be used maxExclusive and maxInclusive specify an upper bound; either but not both may be used

Copyright John Cowan under the GNU GPL124 Value Facets totalDigits specifies the total number of significant digits in a decimal, integer, (non)PositiveInteger, or (non)NegativeInteger value fractionDigits specifies the number of fractional digits in a decimal value

Copyright John Cowan under the GNU GPL125 Pattern Facet Applicable to any type Specifies a regular expression that the data must match XML Schema: If multiple pattern facets are present, the data must match at least one of them RELAX NG: If multiple pattern facets are present, the data must match all of them

Copyright John Cowan under the GNU GPL126 MORE INFORMATION pt,.sxi,.pdf}