[NeXus-tech] continuing progress on nxdl2xsd.xsl
Pete Jemian
prjemian at gmail.com
Thu Dec 4 19:59:54 GMT 2008
nxdl2xsd.xsl is the XSLT translator to convert our NXDL definitions into
XML Schema. Each NXDL will result in a new XML Schema complexType based
on the instructions given.
Status: nxdl2xsd.xsl is working (generates valid XSD, can include
multiple of these together) but still needs some more development before
we can validate NeXus data files using the derived XML Schema files.
Now, I am trying to generate simple and valid test files based on these
rules (for comparison with existing NeXus files). Also, the
nxdl2xsd.xsl code is a bit complicated and might be hard to modify.
When it comes to NXDL groups, we need a special rule that looks like
this in the XSLT:
<xsl:attribute name="name">
<xsl:choose>
<!-- @name was specified, use it (to avoid multiple
elements with same name) -->
<xsl:when test="count(@name)>0"><xsl:value-of
select="@name"/></xsl:when>
<!-- default -->
<xsl:otherwise><xsl:value-of
select="@type"/></xsl:otherwise>
</xsl:choose>
</xsl:attribute>
This chooses the name attribute in a class's XML schema (such as
NXsample.xsd) based on what is found in the NXDL group declarations. If
a name attribute is given in the NXDL for a group, then use it as the
name attribute in the translated XSD file. Default is to get name from
the NXDL type attribute.
for example, these two NXDL lines:
<group name="other_notes" type="NXnote"/>
<group type="NXcharacterization" />
will translate to these XML Schema lines
<xs:element name="other_notes" minOccurs="0" maxOccurs="unbounded"
type="nx:NXnote"/>
<xs:element name="NXcharacterization" minOccurs="0"
maxOccurs="unbounded" type="nx:NXcharacterization"/>
This type of rule is needed to avoid having duplicate name errors
(Unique Particle Attribution violations) in the XML Schema files.
Problems that cropped up were multiple NXlog entries with the same name
in NXsample or multiple NXnote entries in NXentry and NXdetector and
perhaps other similar instances. (This also looks like the intent of
the name attribute in the NXDL group declaration and the metaDTD.)
Also, I'm wrestling with namespace declarations to simplify the header
in the NeXus XML data files. I expect the NeXus XML data file to look
something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- some comments or reference to style sheet may appear here -->
<NXroot
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://definition.nexusformat.org/schema/3.1
NeXus.xsd"
xmlns="http://definition.nexusformat.org/schema/3.1">
<NXentry>
<!-- file content here -->
</NXentry>
<NXentry><!-- as desired --></NXentry>
</NXroot>
Pete
--
----------------------------------------------------------
Pete R. Jemian, Ph.D. <jemian at anl.gov>
Beam line Controls and Data Acquisition, Group Leader
Advanced Photon Source, Argonne National Laboratory
Argonne, IL 60439 630 - 252 - 3189
-----------------------------------------------------------
Education is the one thing for which people
are willing to pay yet not receive.
-----------------------------------------------------------
More information about the NeXus-tech
mailing list