oXygen XML Editor

References

Relax-ng Basics

1. Home page
2. Mailing list for questions on relax ng.
3. RELAX NG. An ISO standard
4. Relax NG book
5. Which syntax
6. Using Jing
7. A history - already!
8. Relax NG, a validation tool?
9. Relax NG and Python
10. XML or compact Syntax?

1.

Home page

James Clark

I've put up a new release of nxml-mode at: thaiopensource.com. This reflects the state of nxml-mode before I took my break. I don't remember whether at that time there was anything critical that had to be done before a new release, but, if there was, it hasn't been done, so it is quite possible that this release is horribly broken. So please try it out and report any regressions.

I've also put a homepage for nxml-mode: thaiopensource.com

2.

Mailing list for questions on relax ng.

James Clark

The consensus seems to be that a public mailing list for RELAX NG users would be useful, so I have set one up: relaxng.org

The RELAX NG home page: relaxng.org

3.

RELAX NG. An ISO standard

James Clark

RELAX NG was published by ISO as an International Standard on 1st December 2003. The full title is:

ISO/IEC 19757-2:2003 Information technology -- Document Schema Definition Language (DSDL) -- Part 2: Regular-grammar-based validation -- RELAX NG

Its ISO Catalogue entry is: iso.org

The text of the published standard is unfortunately not freely available. However, the FDIS text remains available from the SC34 Chairman's site: doe.gov (pdf format)

The only differences I have found between the FDIS text and the published standard are that the Foreword is slightly different and the cover page, headers and footers have been changed in accordance with its change in status. Even the pagination appears to be identical.

At its recent meeting in Philadelphia, SC34 (the body responsible for standardization of RELAX NG in ISO) resolved to proceed with the standardization of the compact syntax by preparing an amendment to the RELAX NG standard (ISO/IEC 19757-2) that adds a new normative Annex. This means that, if everything goes according to plan, the compact syntax will eventually be equal with the XML syntax as regards its standardization status.

4.

Relax NG book

Eric van der Vlist

I am happy to announce a new version of my book "RELAX NG" to be published in December by O'Reilly.

This version is available at the usual URL books.xmlschemat.org

It is now pre-production quality and should be close to the final version which will be available in print Amazon and on line both commercially through Safari O'Reilly and on my site dyomedea.com (and maybe others) under a GFDL gnu licence.

Although the book shouldn't be drastically updated at this point, you are still welcome to submit your feedback using our annotation system.

Compared to the version which was previously on line, this new one has gone through a complete copy editing and should be, thanks to Simon St.Laurent and Tracey Cranston, in much better (American) English and much easier to read.

The layout of the pages is now generated from DocBook using an adaptation of the LDP customisation of Norm Walsh's XSL stylesheets.

This results in a bunch of small pages in a format now familiar to many users and programmers and this should also improve the readability of the web version.

I hope you'll enjoy reading it as much as I have enjoyed writing it!

5.

Which syntax

James Clark

I'm teaching a beginning XML course.

I was teaching RNG before the compact syntax came on the scene, but this semester some students have expressed interest in it. Over the past two days, I wrote a second version of the lecture notes (at catcode.com) to cover compact syntax.

1) Should instructors emphasize the XML syntax or the compact syntax? The XML syntax _is_ the official version, and it's the one used by W3C for SVG, but compact is, well, more compact.

James responds

I don't really have an answer. The compact syntax is an OASIS committee spec, so it's official too, although it hasn't started on any ISO standardization path (yet). If you do emphasize the compact syntax, I think it's important to mention the XML syntax and teach how to get the XML syntax from the compact syntax. Apart from that, I would suggest emphasizing whichever you think your audience will understand more easily.


> Are there any "Official Relax NG Compact Syntax
> Indenting Guidelines"?

No. You can use trang to indent your RNC by using RNC input and RNC output. I put a fair amount of effort into making trang's RNC output indent in a reasonable and systematic way.

The overall objective is to produce a readable schema. Indentation is just one factor that contributes to readability. I find compact schemas easier to read when they are relatively flat. I prefer schemas that follow the following rules:

- always have an implicit top-level grammar
- no nested element patterns; move nested element patterns into separate definitions
- any closing ( on the same line as the opening ); if this makes the line too long or the expression hard to read, then factor part of the expression out into another definition
- closing } either on the same line as the opening { or on a line by itself aligned with the start of the keyword before the opening {

6.

Using Jing

various


I got a NoClassDefFoundError because
jing couldn't find org.xml.sax.ErrorHandler. I believe that when I run this on
a Windows machine, jing is finding these classes right in the 1.4 jvm.

Simon St Lawrence

You might try: sourceforge

Which comes right off of: saxproject.org

I don't think it should have Xerces dependencies, anyway.

David Tolpin adds: It does not have any Xerces dependencies but it does include a SAX2 parser. A parser such as XP or the one from GNU is still required;

James completes it with: XP isn't maintained and doesn't support SAX2. IIRC, the GNU jaxp parser does not fully implement SAX2 (in that it doesn't allow ContentHandler to be set during a parse), which makes it not work with Jing. I would recommend Crimson (available from Apache) as a small and conformant parser that works with Jing.

7.

A history - already!

James Clark

> FWIW, the first compact syntax I saw for XML Schema was in the XML Query 
> Formal Semantics,

I would say that the early drafts of the XQuery formal semantics provided a compact syntax not for XML Schema, but for an XML type system similar to XDuce. Since XDuce via TREX was also one of the starting points for RELAX NG, there was at that time a lot of semantic similarity between RELAX NG and the XQuery Formal Semantics type system. As XQuery has evolved its semantics to be more compatible XML Schema, so that semantic similarity has lessened.


> and was designed by Phil Wadler, Mary Fernandez, and 
> Jerome Simeon. It was kicked around in the Working Group for quite a 
> while before being published here:

> http://www.w3.org/TR/2000/WD-query-algebra-20001204/

> I suspect that this compact notation may have influenced the others.

It did. It's explicitly acknowledged in the RNC spec: relaxng.org

XDuce was also defined in a compact syntax and preceded both TREX and the XQuery work. I believe Phil had some involvement with XDuce as well.


> I'd venture a guess that Relax-NG, via TREX, was more
> influenced by Brzozowski's 1964 paper "Derivatives of
> regular expressions", which uses a purely syntactic
> approach.  (The derivative algorithm, for instance,
> is what makes the interleave operator feasible.)

Well, without that paper there probably wouldn't be RELAX NG. However, it didn't directly influence the design of TREX. I had decided the basic semantics I wanted -- XDuce type system, plus namespaces, plus attribute/element content models, plus an & operator that did the right thing -- before I knew whether it was feasible to implement it. Then I found (via Google) Mark Hopkins' regex package which, together with the existing work on RELAX implementation, was the starting point for my initial TREX implementation. Mark Hopkins acknowledges Brzozowski as the originator of the derivative approach. Since then Murata-san has discovered work on something called shuffle automata which he has used to implement interleave. See citeseer.nj.nec.com

8.

Relax NG, a validation tool?

James Clark


> It is my impression that Relax NG, as well as other modern schema languages,
> is implemented with idea in mind that a schema is a validation tool.

Not exactly. I see the role of a schema language as being to define the interface between components that communicate using XML. Validation is one aspect of this: it's runtime checking of compliance with the interface. I think it's important that when you have an interface you can mechanically enforce it. But more important than this is just the fact of having an interface that is rigorously defined, yet human understandable. If all you have to define your interface is English prose, it is very likely that different people will interpret it slightly differently. If all you have is XSD, then you had better have a tool like XMLSpy if you want people to understand it.

For a schema language to work well in this role, as an XML processing component interface definition language, it's vital that the schema language doesn't do anything other than define a set of XML documents. If a schema does other random stuff useful for processing (like tell you how to turn the XML document into Java objects or add default attributes), then it's making the components that use it as an interface unnecessarily tightly coupled. Maybe it's wishful thinking on my part, but I see a growing realization of this point in the move towards service-oriented architectures and "typeless" web services.

9.

Relax NG and Python

A.M. KUCHLING


> Is there someplace I can look for Python support for RELAX NG?

I have a page of rough notes at http://www.amk.ca/notes/rng.html . libxml2 (www.xmlsoft.org) includes a RELAX NG validator and comes with Python bindings.

> I've written quite a bit of a parser for the compact syntax. I'm
> using PLY to build the parser: http://systems.cs.uchicago.edu/ply/.
> I'd like to know if it's already been done before continuing.

David Mertz has a Python script that's supposed to translate from RNC to RNG, but when I tried it on the RELAX NG schema, it crashed. There's a link to it from my notes.

10.

XML or compact Syntax?

Mike Fitzgerald and David Carlisle



>Except there is one problem: At a given point you are 
>addicted. Strangely, though, all the RNC detox centers are empty.

Problem? No, that's called 'shear joy'. .. and I think those centers are going to start filling up....

BTW, here is a (complete?) list of RNC symbols, for those of you who wish to check in:

()   general purpose pattern grouping
{}   only used on element and attribute patterns, 
to enclose the entire content model of that element or attribute.
|    choice 
&    interleave
,    sequence 
=    only placed to the right hand side of a <define> name.

> In case of Relax NG the compact non-XML
> syntax clearly beats the XML syntax.

A lot of people feel that way. I don't though. I personally find the XML syntax to be significantly easier to read and understand than the RELAX NG compact syntax.

I can second that. It's good that James gave us two alternatives, but every time I have to read RNC, I have to go back and check what the symbols mean. Admittedly, I don't read a lot of RNC, or I would have learned the syntax. But as a causal user, I find the XML syntax a better trade-off between "self-describing markup" and ease of authoring. I doubt Aunt Trudie is a less causal user than I am :=)

In my experience, once you're familiar with RELAX NG, the compact syntax becomes natural -- to the point that you don't want to live without it. In fact, I suspect that any RNG aficionados would much prefer RNC and can't go back to the XML syntax for one reason: It's much quicker to develop schemas by hand, once you have RNG in you back pocket. And twice-blessed by Trang, which can translate RNC to DTD, RNG, or XML Schema, you don't get yourself painted in a corner. Except there is one problem: At a given point you are addicted. Strangely, though, all the RNC detox centers are empty.