110 likes | 256 Views
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
E N D
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’
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 (orDTD). • 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 at Oasis. • A 3-part series of "XML Matters" columns entitled "Kicking back with RELAX NG" by David Mertz (Part 1, Part 2, 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.