NeXus and XML?

C.M.Moreton-Smith at rl.ac.uk C.M.Moreton-Smith at rl.ac.uk
Thu Dec 23 16:13:11 GMT 1999


Here is something to ponder over the Christmas/New Millenium break.

If you read the computing press or even just open a computing magazine, it
will be fairly obvious that one of the current "flavours of the month" is
XML.  Although not a part of NeXus, XML does have relevance to what we are
doing.

First of all, A NeXus file can be trivially converted into XML, I've
attached a very simple NeXus file converted to XML as an example.  This is
an interesting thing to be able to do and gives the advantages (and
disadvantages) of data stored in an ASCII file whilst maintaining a NeXus
structure to the data.

Secondly, and more importantly, it is possible to validate this file against
a separate description of what should be in the file.  We currently have no
tools to validate NeXus files in this way.  Neither do we have a language
with which to describe the structure of a NeXus file formally, a
prerequisite to building an automated means of differentiatiating valid
NeXus files from an invalid ones.

There are some definite possibilities here:

1) Describe permissible NeXus file structures with XML DTDs (Document Type
Definitions - see the attached nexus.dtd).

2) Develop tools to validate NeXus files easily by converting NeXus files to
XML and then using automated checking on them (we don't necessarily need to
store NeXus files permanently in XML).

3) Another possibility is to use XSL (Extensible Stylesheet Language) in a
similar manner to automatically transform a valid NeXus file from one format
to another (say triple axis to inelastic - where is makes sense to do so).

4) A final rather exciting possibility is to use XSL in conjunction with the
emerging W3C SVG ( Standardized Vector Graphics ) standard to automatically
transform the plottable data from a NeXus XML file into browser graphics
directly.

The XML files attached are "NeXus.xml" (a simple NeXus file in XML) and
"NeXus.dtd" a DTD which describes valid content for the other file.  I
created the XML file with a delightful little utility called the Microsoft
XML notepad - simple but sweet.  It can be downloaded for free from

	http://msdn.microsoft.com/xml/notepad/xpsetup.exe

and gives a good tree display (see picture) of the NeXus/XML structure.  I
believe there are also several Java tools for doing this sort of thing.

For validating the XML file against the DTD, I've used another MS tool which
runs at the command line.  It gives error messages when the file does not
conform to the description and is very simple to use.  Here is a simple
validation test (which failed).

X:\Development\genie>xmlint nexus.xml
NeXus.xml
        The element 'program_name' is used but not declared in the
DTD/Schema.
        URL: file:///X:/Development/genie/NeXus.xml
        Line 00029:       <program_name>Microsoft XML Notepad
V1.5</program_name>
        Pos  00021: --------------------^

This tool is available from

	http://msdn.microsoft.com/downloads/tools/xmlint/xmlint.zip

I suspect there are also many Java tools which do this (XML is very much a
cross platform standard).

A good resource for general info about XML is

	http://xml.com/pub/98/10/guide1.html

and
	http://xml.org

also has a lot of pointers.


Merry Christamas and Happy new millenium

	Chris

--
Chris Moreton-Smith, Software Development Manager
ISIS Science Instrumentation, CCLRC, Chilton, Didcot, OXON OX11 0QX
Telephone: +44 (0) 1235 446544, Fax: +44 (0) 1235 445720
Email: C.Moreton-Smith at rl.ac.uk


-------------- next part --------------
A non-text attachment was scrubbed...
Name: NeXus.dtd
Type: application/octet-stream
Size: 2912 bytes
Desc: not available
Url : http://lists.nexusformat.org/pipermail/nexus/attachments/19991223/789832f9/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NeXus.xml
Type: application/octet-stream
Size: 1802 bytes
Desc: not available
Url : http://lists.nexusformat.org/pipermail/nexus/attachments/19991223/789832f9/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NeXus in XML.jpg
Type: image/jpeg
Size: 164526 bytes
Desc: not available
Url : http://lists.nexusformat.org/pipermail/nexus/attachments/19991223/789832f9/attachment.jpg 


More information about the NeXus mailing list