Skip to content

Commit

Permalink
add extends attribute to fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Jan 16, 2025
1 parent fb7142d commit f3a1ff7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions nxdl.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,47 @@ https://stackoverflow.com/a/48980995/1046449 -->
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="extends" use="optional">
<xs:annotation>
<xs:documentation>
The ``extends`` attribute allows to specify which field
in the inheritance hierarchy this field is derived from.

This attribute is to be used in cases where there is an ambiguity
in the inheritance. An example are the ``AXISNAME`` and ``DATA``
fields in ``NXdata``, which are both of type ``NX_NUMBER``.
Thus, when specializing ``NXdata`` in an application definition,
``extends`` attribute allows to specify whether a field in the
specialized ``NXdata`` is an ``AXISNAME`` and ``DATA``.

For example, consider the following NXDL snippet:

<definition xmlns="http://definition.nexusformat.org/nxdl/3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" category="application" name="NXiv_temp" extends="NXsensor_scan" type="group" xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd">
<doc>
Application definition for temperature-dependent IV curve measurements.
</doc>
<group type="NXentry">
<group type="NXdata">
<doc>
This NXdata contains multiple fields. Temperature and voltage are supposed to specialize `AXISNAME`, whereas
`current` is specializing `DATA`.
</doc>
<field name="temperature" type="NX_NUMBER" extends="/NXdata/AXISNAME"/>
<field name="voltage" type="NX_NUMBER" extends="/NXdata/AXISNAME"/>
<field name="current" type="NX_NUMBER" extends="/NXdata/DATA"/>
</group>
</group>
</definition>

Here, the ``extends`` attribute is used to specify that the ``temperature`` and ``voltage`` fields are specializations
of the ``AXISNAME`` field, whereas the ``current`` field is a specialization of the ``DATA`` field.

Note that the ``extends`` keyword shall only be used in cases where there is an ambiguity in the inheritance, such as
the example above. The ``extends`` attribute must not be used when such ambiguity does not exist. Especially, it is
not alllowed to specify the ``extends`` attribute for fields that are not part of the inheritance hierarchy.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="nx:nameTypeAttributeGroup"/>
</xs:extension>
</xs:complexContent>
Expand Down

0 comments on commit f3a1ff7

Please sign in to comment.