# Presentation: 354148

## LAS-XML, Validation, and RELAX NG

- Jon Callahan(standing in for Roland Schweitzer)

## LAS use of XML

- LAS (will) store all ‘configuration information’ in XML documents
- Server configuration
- User Interface components
- Dataset descriptions
- Variables
- User Interface presentation
- Product generation ‘hints’
- Data access ‘hints’

## LAS use of XML

## Sister servers

## Improving our use of XML

- GOALS:
- Have _all_ configuration information in XML
- Be able to create a schema for validation
- Better separate UI vs. product server info
- Expanded set of information
- Clean up inconsistencies

## New dataset XML

**<lasdata version="6.5">**
**   ****<dataset**
**        ****doc="http://www.cdc.noaa.gov/cdc/data.coads.ltm.html"**
**        ****ID="CDC014"**
**        ****name="COADS LTMs">**
**      ****<variable**
**            ****ID="V2"**
**            ****name="Sea Surface Temperature"**
**            ****units="degC"**
**            ****url="file://Datasets/coads_2d_g_std/sst.mean.nc#sst">**
**         ****<grid IDREF="G88"/>**
**      ****</variable>**
**      ****<variable> ... </variable>**
**      ...**
**   ****</dataset>**

## New dataset XML

**    ****<grid ID="G88">**
**      ****<axis IDREF="CDC014-lon17"/>**
**      ****<axis IDREF="CDC014-lat18"/>**
**      ****<axis ID="CDC014-time88" type="t" units="month">**
**         ****<arange size="120" start="1990-01-01" step="1"/>**
**      ****</axis>**
**    ****</grid>**
**    ****<axis ID="CDC014-lon17" type="x" units="degrees_east">**
**      ****<arange size="180" start="1" step="2"/>**
**    ****</axis>**
**    ****<axis ID="CDC014-lat18" type="y" units="degrees_north">**
**      ****<arange size="90" start="-89" step="2"/>**
**    ****</axis>**
**</lasdata>**

## ‘Well formed’ vs. ‘valid’

- 10% of XML documents have errors!
- ‘Well formed’ means that the XML syntax is correct.
- ‘Valid’ means that the XML conforms to a schema (or DTD).
- Tools are available to validate XML against your schema.
- Automatic validation means less user support!

## Writing schemas with RELAX NG

- RELAX NG is a newly popular tool for writing XML schemas.
- RELAX NG focuses on XML tree structure(not element content).
- RELAX NG schemas are easy to write.
- RELAX NG schemas are easy to read.
- “Working with RELAX NG is fun!” (Roland)

## RELAX NG schema for <lasdata>

**<define name="Lasdata">**
**   ****<element name="lasdata">**
**      ****<attribute name="version"/>**
**      ****<interleave>**
**         ****<oneOrMore>**
**            ****<ref name="Dataset"/>**
**         ****</oneOrMore>**
**         ****<oneOrMore>**
**            ****<ref name="Grid"/>**
**         ****</oneOrMore>**
**         ****<oneOrMore>**
**            ****<ref name="Axis"/>**
**         ****</oneOrMore>**
**      ****</interleave>**
**   ****</element>**
**</define>**

## Useful links

- The _[RELAX NG Tutorial](http://www.oasis-open.org/committees/relax-ng/tutorial.html)_ at Oasis.
- A 3-part series of "XML Matters" columns entitled "Kicking back with RELAX NG" by David Mertz (_[Part 1](http://www-106.ibm.com/developerworks/xml/library/x-matters25.html)_, _[Part 2](http://www-106.ibm.com/developerworks/xml/library/x-matters26.html)_, and Part 3).
- An article about the design philosophy behind RELAX NG.
- The text of a book on RELAX NG to be published by O'Reilly & Associates.
- A C-library that includes RELAX NG validation with Perl bindings via XML-LibXML.