[Nexus] Fwd: Re: [NeXus-tech] XML and new attribute

Pete Jemian jemian at anl.gov
Fri Feb 13 16:40:09 GMT 2015



On 2/13/2015 9:07 AM, Eugen Wintersberger wrote:
>> >In the NXDL specification file, the only attributes allowed to the field
>> >tag are those described in the nxdl.xsd file.  Attributes destined for
>> >the HDF5 file (like type, name, units, long_name, etc.) with fixed
>> >values must be specified with the "enumeration" element, which is a
>> >child of the field element to which they apply.
> Now I am a bit confused: I thought name, units, etc. are defined in the
> nxdl.xds and thus go into the tag (as shown below)
>    <field name="..." ...>
>

The attributes "name", "type", "units", "long_name" are defined in 
nxdl.xsd for use in NXDL files so that the NXDL can declare the name of 
an element, the NeXus storage type of the object, and the *type* 
engineering units of the data, respectively.

To test these various examples, I had to construct a test NXDL file and 
validate it against the nxdl.xsd file (which includes the nxdlTypes.xsd 
file).

You are right (passes validation) that for the "name", "long_name", and 
"type" attributes, you can specify them such as this:

   <field name="phi" type="NX_FLOAT" long_name="phi (degrees)"/>

But, this a requirement for specific units does not validate:

   <field name="phi" type="NX_FLOAT" units="degrees"/>

The validation error reported:
The value 'degrees' of attribute 'units' on element 'field' is not valid 
with respect to its type, 'anyUnitsAttr'.

In this example "degrees" is not an allowed value for the "units" 
attribute of a field in an NXDL file.  The allowed values for the units 
attribute come from the list "anyUnitsAttr" in the nxdlTypes.xsd file. 
The most appropriate value here is "NX_ANGLE" (documentation says: 
example: degrees or radians or arcminutes or).  The point of this 
indirection is that NeXus allows the specific units of any field to be 
specified in compatible terms. This *feature* is not validated by NeXus.

To allow this one particular NXDL to require units="degrees" in this 
instance while allowing NeXus to retain the planned flexibility for to 
specify the units, it is necessary for this instance to use an 
"enumeration" field to impose the intended requirement, such as:

   <field name="phi" type="NX_FLOAT">
     <attribute name="units">
       <enumeration>
         <item value="degrees"/>
       </enumeration>
     </attribute>
   </field>

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 mailing list