Return to LAS FAQ

Keeping files separate with XML includes


How can I keep the XML manageable when I have many data sets?


In most cases it will be convenient to have a separate XML file describing each dataset on your server. This can be achieved with XML "include" syntax. Using XML includes will allow you to add and delete datasets easily and will make hand editing the XML and debugging those edits much simpler.

XML has a (rather ugly) include syntax which lets you create an XML file which includes the contents of other XML files. The file doing the including will begin by defining an 'entity' like this:

<?xml version='1.0' ?>
<!DOCTYPE spec SYSTEM "spec.dtd" [
<!ENTITY coads_climatology SYSTEM "coads_climatology.xml">

and will include the file "coads_climatology.xml" when the following entity appears:


Note 1: The included .xml files must all exist in the same directory.

Note 2: The Makefile in the lasxml/server/ directory only checks whether the file named las.xml has changed. To update the interface after you have made changes to one of the included files you must 'touch las.xml'.


In the context of LAS and the las.xml file you should start by creating XML files for the datasets you will use. They will be just like the standard las.xml file except that they should only contain the datasets, grids and axes elements. They must not contain the <lasdata></lasdata> or <operations></operations> tags.

The script, which generates XML files from netCDF files, has an --out_inc flag which causes output to be written in a format suitable for inclusion in a master XML file. It is used like this: --out_inc template.xml my_data.xml

As an example, here is the complete coads_climatology.xml file:

   name="COADS Climatology"
  <institution name="NOAA/PMEL" url=""/>
   <airt name="AIR TEMPERATURE" units="DEG C">
    <link match="/lasdata/grids/coads_climatology_nc_grid"/>
   <sst name="SEA SURFACE TEMPERATURE" units="Deg C">
    <link match="/lasdata/grids/coads_climatology_nc_grid"/>
  <link match="/lasdata/axes/coads_climatology_nc_COADSX"/>
  <link match="/lasdata/axes/coads_climatology_nc_COADSY"/>
  <link match="/lasdata/axes/coads_climatology_nc_TIME"/>
 <coads_climatology_nc_COADSX type="x" units="degrees_east">
  <arange start="21" step="2" size="180"/>
 <coads_climatology_nc_COADSY type="y" units="degrees_north">
  <arange start="-89" step="2" size="90"/>
 <coads_climatology_nc_TIME type="t" units="month">
  <arange start="1-1-16" step="1" size="12"/>

And here is a complete las.xml file which includes coads_climatology.xml and levitus_climatology.xml:

<?xml version='1.0' ?>
<!DOCTYPE spec SYSTEM "spec.dtd" [
<!ENTITY coads_climatology SYSTEM "coads_climatology.xml">
<!ENTITY levitus_climatology SYSTEM "levitus_climatology.xml">

 <institution name="Pacific Marine Environmental Lab"
 <!-- Define properties -->
 <!-- Define properties -->
<operations url="">
&coads_climatology; &levitus_climatology; </lasdata>

Jonathan Callahan:
Last modified: August 8, 2000