[NeXus-definitions-tickets] [NeXusDefinitions] #28: NXDL groups and name attribute - NeXus design flaw?
NeXus Base Classes and Instrument Definitions
noreply at nexusformat.org
Thu Dec 4 22:51:17 GMT 2008
#28: NXDL groups and name attribute - NeXus design flaw?
------------------------+---------------------------------------------------
Reporter: Pete Jemian | Owner:
Type: defect | Status: new
Priority: major | Keywords:
------------------------+---------------------------------------------------
There is a problem with the names of groups when constructing XML Schema
from the NXDL. Easiest to illustrate this by a brief NXDL excerpt:
{{{
<group type="NXlog"/>
<field name="name"/>
<field name="date"/>
<field name="place"/>
<group type="NXlog" name="second_log"/>
}}}
Present NeXus rules say to name each of the NXlog entries as '''NXlog.'''
This would result in this XSD (XML Schema):
{{{
<xs:element name="NXlog" minOccurs="0" maxOccurs="unbounded"
type="nx:NXlog" />
<xs:element name="name" minOccurs="0" maxOccurs="1" type="nx:NX_CHAR" />
<xs:element name="date" minOccurs="0" maxOccurs="1" type="nx:NX_CHAR" />
<xs:element name="place" minOccurs="0" maxOccurs="1" type="nx:NX_CHAR" />
<xs:element name="NXlog" minOccurs="0" maxOccurs="unbounded"
type="nx:NXlog">
<!-- what to do with the name="second_log" information from the NXDL?
-->
</xs:element>
}}}
Since any of these elements are optional, the XSD cannot validate whether
or not an appearance of NXlog is the first one or the second one. XSD
rules do not permit this definition to exist. It is reported in oXygen as
a violation of "Unique Particle Attribution" and causes the XSD to be
invalid.
One way to satisfy the XSD rules is to set the default rule (in NXDL) for
group declarations that the resulting XSD element name will be the NXDL
group's type. '''''If''''' a '''name''' attribute is present in the NXDL
group declaration, then the '''name''' attribute will be used as the name
of the resulting XSD element. The XSD (which is now valid) then becomes:
{{{
<xs:element name="NXlog" minOccurs="0" maxOccurs="unbounded"
type="nx:NXlog" />
<xs:element name="name" minOccurs="0" maxOccurs="1" type="nx:NX_CHAR" />
<xs:element name="date" minOccurs="0" maxOccurs="1" type="nx:NX_CHAR" />
<xs:element name="place" minOccurs="0" maxOccurs="1" type="nx:NX_CHAR" />
<xs:element name="second_log" minOccurs="0" maxOccurs="unbounded"
type="nx:NXlog"/>
}}}
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.)
* Is this a design flaw in the definitions?
* Should the base classes be allowed to specify the name of a group?
--
Ticket URL: <http://trac.nexusformat.org/definitions/ticket/28>
NeXus Base Classes and Instrument Definitions <http://www.nexusformat.org/>
NeXus Base Classes and Instrument Definitions
More information about the NeXus-definitions-tickets
mailing list