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.

Slides:



Advertisements
Similar presentations
XML I.
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.
Data-centric XML Other Schema Languages Montag, 5. Juli 2010.
XSLT 11-Apr-17.
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.
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.
Review Writing XML  Style  Common errors 1XML Technologies David Raponi.
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.
XML Schema Definition Language
Lecture 14 XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name.
Fonts and colors Times New Roman “quotes” Trebuchet "quotes" yellow blue pink green violet.
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 Introduction What is XML –XML is the eXtensible Markup Language –Became a W3C Recommendation in 1998 –Tag-based syntax, like HTML –You get to make.
29-Jun-15 JAXB Java Architecture for XML Binding.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Unit 4 – XML Schema XML - Level I Basic.
Introduction to XML: Part I By Sandeep Jangity CS 157B, Section 2 Dr. Lee.
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.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Document Type Definition.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
IS432 Semi-Structured Data Lecture 3: XSchema Dr. Gamal Al-Shorbagy.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
Chapter 4: Document Type Definitions. Chapter 4 Objectives Learn to create DTDs Validate an XML document against a DTD Use DTDs to create XML documents.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Schemas Ellen Pearlman Eileen Mullin Programming the Web Using XML.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
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.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
XML Syntax - Writing XML and Designing DTD's
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 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.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
IS432 Semi-Structured Data Lecture 2: DTD Dr. Gamal Al-Shorbagy.
An OO schema language for XML SOX W3C Note 30 July 1999.
1 Credits Prepared by: Rajendra P. Srivastava Ernst & Young Professor University of Kansas Sponsored by: Ernst & Young, LLP (August 2005) XBRL Module Part.
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,
CSE3201 Information Retrieval Systems DTD Document Type Definition.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
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.
Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Introduction to XML XML – Extensible Markup Language.
Introduction to DTDs. Introduction We learned how to structure information using XML Learned XML grammar Learned the rules for XML encoding We learned.
Copyright 2004 John Cowan 1 Infinite Diversity in Infinite Combinations why one schema language is not enough John Cowan.
XML Validation II Advanced DTDs + Schemas Robin Burke ECT 360.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name value pair;
Using DSDL plus annotations for Netconf (+) data modeling Rohan Mahy draft-mahy-canmod-dsdl-01.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML Validation III Schemas + RELAX NG Robin Burke ECT 360.
XML Extensible Markup Language
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
Infinite Diversity in Infinite Combinations
XML QUESTIONS AND ANSWERS
RELAX NG 2-Aug-18.
RELAX NG 18-Sep-18.
RELAX NG 19-Feb-19.
Presentation transcript:

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.

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 languages, RELAX and TREX –It is not a W3C standard, but is an OASIS standard OASIS is the Organization for the Advancement of Structured Information Standards –ebXML (Enterprise Business XML) is a joint effort of OASIS and UN/CEFACT (United Nations Centre for Trade Facilitation and Electronic Business) –OASIS developed the highly popular DocBook DTD for describing books, articles, and technical documents RELAX NG has recently been adopted as an ISO/IEC standard

Design goals Simple and easy to learn Uses XML syntax –But there is also a “concise” (non-XML) syntax Does not change the information set of an XML document –(I’m not sure what this means) Supports XML namespaces Treats attributes uniformly with elements so far as possible Has unrestricted support for unordered content Has unrestricted support for mixed content Has a solid theoretical basis Can make use of a separate datatyping language (such W3C XML Schema Datatypes)

RELAX NG tools Jing –An open source validator written in Java Sun’s MSV –Another validator DTDinst –Translates from DTDs into RNG (RELAX NG) syntax or RNG “compact” syntax Trang –Translates RNG compact syntax into RNG syntax –Translates RNG or RNG compact syntax into DTDs Sun’s RELAX NG Converter –Translates DTDs into RNG syntax (but not well) –Translates an XML Schema subset into RNG syntax (imperfectly)

Basic structure A RELAX NG specification is written in XML, so it obeys all XML rules –The RELAX NG specification has one root element –The document it describes also has one root element –The root element of the specification is element –If the root element of your document is book, then the RELAX NG specifications begins: –and ends:

Data elements RELAX NG makes a clear separation between: –the structure of a document (which it describes) –the datatypes used in the document (which it gets from somewhere else, such as from XML Schemas) For starters, we will use the two (XML-defined) elements: –... (usually written ) Plain character data, not containing other elements – (usually written ) Does not contain anything Other datatypes, such as... are not defined in RELAX NG –To inherit datatypes from XML Schemas, use: datatypeLibrary=" as an attribute of the root element

Defining tags To define a tag (and specify its content), use Example: The DTD Translates to: Note: As in the DTD, the components must occur in order

RELAX NG describes patterns Your RELAX NG document specifies a pattern that matches your valid XML documents For example, the pattern: Will match the XML: David Matuszek

Easy tags... The enclosed content occurs zero or more times... The enclosed content occurs one or more times... The enclosed content occurs once or not at all... Any one of the enclosed elements may occur

Example

Enumerations The... pattern matches a specified value –Example: male female The contents of are subject to whitespace normalization: –Leading and trailing whitespace is removed –Internal sequences of whitespace characters are collapsed to a single blank

More about data Remember: To inherit datatypes from XML Schemas, add this attribute to the root element: datatypeLibrary = " You can access the inherited types with the tag, for instance, –The pattern must match the entire content of the enclosing tag, not just part of it – If you don't specify a datatype library, RELAX NG defines the following for you (along with and ): – : No whitespace normalization is done – : A sequence of characters containing no whitespace

... is used as “fat parentheses” Example: – choice #1 choice #2

Attributes Attributes are defined practically the same way as elements: –... Example: – Matches: – David Matuszek

More about attributes With attributes, as with elements, you can use,, and It doesn’t make sense to use or with attributes In keeping with the usual XML rules, –The order in which you list elements is significant –The order in which you list attributes is not significant

Still more about attributes can be (and usually is) abbreviated as However, can not be abbreviated as –If an element has no attributes and no content, you must use explicitly

pattern matches a whitespace- separated list of tokens, and applies the pattern to those tokens –Example:

... allows the contained elements to occur in any order is more sophisticated than you might expect –If a contained element can occur more than once, the various instances do not need to occur together

Interleave example

allows mixed content, that is, both text and patterns If pattern is a RELAX NG pattern, then pattern is shorthand for pattern

Example of Pattern: Matches: This is not a great example, but it should suffice. Without this we get one bold or one italic

The need for named patterns So far, we have defined elements exactly at the point that they can be used –There is no equivalent of:...use person several places in the DTD... –With the RELAX NG we have discussed so far, each time we want to include a person, we would need to explicitly define both person and name at that point: The element solves this problem

Syntax of...usual RELAX NG elements, which may include:...usual RELAX NG elements, attributes, groups, etc.

Use of To write a, –Make the root element of your specification Hence it should say xmlns=" –Use, as the element, a pattern that matches the entire (valid) XML document –In each element, write a pattern that you want to use other places in the specification –Wherever you want to use a defined element, put –Note that defined elements may be used in definitions, not just in the element Definitions may even be recursive, but Recursive references must be in an element, not an attribute

Long example of XML is case sensitive-- Note that defined terms are capitalized differently

Common usage I A typical way to use RELAX NG is to use a with just the root element in and every element described by a...more...

Common usage II

Replacing DTDs With and multiple s, we can do essentially the same things as a DTD –Advantages: RELAX NG is more expressive than a DTD; we can interleave elements, specify data types, allow specific data values, use namespaces, and control the mixing of data and patterns RELAX NG is written in XML RELAX NG is relatively easy to understand –Disadvantages RELAX NG is extremely verbose –But there is a “compact syntax” that is much shorter RELAX NG is not (yet) nearly as well known –Hence there are fewer tools to work with it –This situation seems to be changing

The End So by this maxim be impressed, USE THE TOOLS THAT WORK THE BEST. Do not yield your sovereign judgment, To any sort of political fudgement. The criterion of sound design Should be, must be, your guideline. And if you're designing documents, Try RNG. We charge no rents. -- John Cowan