Repository navigation
Define NeXus attributes of all fields and groups, and make content links independent of storage - #1669
Conversation
|
Alternative to #1558 |
7915664 to
18936e1
Compare
96f6a20 to
c12efdb
Compare
|
Documentation preview: https://manual.nexusformat.org/pr-preview/pr-1669/ (built from 4d09f5f) This comment is updated on every push to the branch. |
|
I have a fundamental objection to defining I feel slightly less strongly about the |
This PR does not allow that.
Why in NXDL: the definitions are the contract that validators and readers use. Every NeXus file must have
FYI this PR is still a draft, there are some other corner cases to be dealt with before I propose it to the NIAC. I added comments to other PRs that are somewhat related so the authors are aware of the approach in this PR. |
|
@woutdenolf thanks for the draft, I appreciate that you tried to address the points we discussed w.r.t., among others, #1410 and #1558 directly.
How should these fit into this new structure? |
|
Regarding |
I only added target, units and long_name for now to investigate the approach. I did not look at the others yet (messy as you pointed out). Ideally they would be added in the same way.
Yes I think that's Ray's comment, not necessarily the presence of NX_class itself. Something needs to fail (ideally the XML validation itself) when the base class does not fix the NX_class attribute to the correct value (enumeration with one value as usual). |
a97dcbf to
f2711f1
Compare
9ce4ad7 to
2c13e7e
Compare
2c13e7e to
c9dc761
Compare
de14633 to
43cb4e9
Compare
43cb4e9 to
b484aba
Compare
b484aba to
01e49b3
Compare
52b5315 to
f3d71c1
Compare
9adb0e5 to
038edc5
Compare
… links by content State presented at the NIAC on 2026-10-29.
…nks independent of storage Changes after the NIAC of 2026-10-29.
Rules that a class states (fieldAttributes, occurrence, recommended, valueFrom, @NX_class, @Units, ...) now use NeXus terms; content terms stay for statements about data files. Also fix a few unrelated wording errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- every content group in a NeXus file must have @NX_class - the type of an NXDL group must be a base class (Python syntax check) - nameType="any" means a name no other NeXus item of the group defines - a content field whose NeXus field has a units category must have @Units - state advice to writers as rules of the classes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d vocabulary of NXDL Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s or uses Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…perties Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #1668.
Closes #1670.
This PR makes five changes. Each is described below as before and after, followed by what the NIAC should decide.
Review tips: start with
manual/source/design.rst(sections "Terms at five levels" and "Links"), thenbase_classes/NXobject.nxdl.xml, and innxdl.xsdthe typesfieldAttributesType,groupAttributeType(which carriesvalueFrom),valueFromTypeandlinkType.1.
fieldAttributes: NeXus attributes of every fieldBefore
@units,@target,@long_name, …) were described only in prose. No NXDL file defined them, so a validator that reads only NXDL files did not know them.nxdl.xsddeclared XML attributes of the NXDL field with the same names (long_name,interpretation,stride,data_offset). Such a declaration constrains only.nxdl.xmlfiles, never a data file.After
fieldAttributes, the last child of an NXDL group or of the NXDL definition of a base class (at most one). Its NXDL attributes define NeXus attributes that any field directly in that NXDL group or class may have, whether or not the class defines that field; not fields in nested groups.NXobjectuses it for every field:@target,@units,@long_name,@interpretation,@calibration_status,@stride,@data_offsetand@variant.NXroot, which does not extendNXobject, has a copy; a test keeps both the same. This supersedes addtargetattribute toNXobjectusing new field super-type #1558, which proposed an NXDL fieldFIELDNAMEwithnameType="any"inNXobject: that matches only names that no other NeXus item of the group defines, so it would miss named fields such asdataofNXdetector.fieldAttributesof the enclosing NXDL group, then those of the NXDL groups that define the same NeXus group in the application definitions this one extends, then those of its class, then those of the classes that class extends (seefieldAttributesTypeinnxdl.xsd).*for the field name, such as/NXobject/*@units.fieldAttributesdirectly in an application definition is rejected by the repository's Python syntax check (dev_tools, run in CI): no NeXus group has an application definition as its type.@units: a content field that a NeXus field with a units category describes (such asunits="NX_LENGTH") must have the content attribute@units, with units of that category.long_name,interpretation,strideanddata_offsetof the NXDL field are deprecated. No NXDL file uses them.To decide
fieldAttributesand its precedence? The precedence covers application definitions that extend each other, but not yet base classes that extend base classes (for example the 62 that extendNXcomponent).@interpretationand@long_namemove fromNXobjecttoNXdata? The prose ties them to plotting, but they are about the field itself, not about a plot, and content links share content attributes: defined only inNXdata, no NeXus attribute would describe them at the other end, in content groups of classNXdetector,NXsample, ….@strideand@data_offsetstay? They describe how values are stored when not in C order (Data Rules > Non C Storage Order), which looks like a matter of storage. Zarr stores the order itself; HDF5 cannot.nxdl.xsdin a later NXDL version? Until then,strideanddata_offsetkeepdefault="1"there, so a schema-aware reader still gives every NXDL field these XML attributes.2.
valueFrom="class": the value of@NX_classBefore
@NX_classis, except a one-value enumeration repeated in every class.After
valueFrom="class", of NXDL attributes in NXDL groups and definitions: the value of this NeXus attribute is the type of the NeXus group it is an attribute of, a class name such asNXsample.NXobjectandNXrootuse it for@NX_class. The class page ofNXsample, for example, shows "Obligatory value:NXsample".valueFromcombined with an NXDL enumeration is rejected by the Python syntax check, not bynxdl.xsd: XSD 1.0 cannot express that rule.To decide
valueFromas an XML attribute? As a child element instead,nxdl.xsdcould offer a choice between it and an NXDL enumeration, so any XSD validator would reject the combination. The alternative, a one-value enumeration in every class, also needs a Python check and repeats the class name in every definition.3.
@NX_classis requiredBefore
@NX_class. The prose (File Format, Data Rules) said that the class of a group is inNX_class, but not that it is required, and nothing for the root.After
NXobjectandNXrootdefine@NX_classwithoptional="false".@NX_class, whether or not a NeXus group describes it. Without it, a validator could not tell the class of the group, and the class rule would never reach it.nxdl.xsd, Design).NXobjectalso defines@targetfor every group.To decide
@NX_classtoday?4. Content links: the same content, however it is stored
Before
@target;nxdl.xsdcalled the XML attributetargetof the NXDL link only a suggestion of the value of@target.After
@targetis the path of another one, its target, with the same shared content:@target;@target, and the shared content of its content fields and groups, under their names.@target; if it has one, for example because an HDF5 hard link makes both paths one object, its value is its own path.@targetis always a path in the content tree (fix target attribute for external file links #842).targetof the NXDL link is a class path. It names the NeXus field or group whose content must be the same. The value of@targetdoes not have to match it.napimountof the NXDL link is deprecated, and the manual marks the HDF5 attributenapimountof NAPI files as deprecated.To decide
@target?@targetinstead of comparing? Nothing needs comparing when the storage makes both paths one object (HDF5 hard or soft link). A 1-to-1 virtual dataset guarantees the values only: its content attributes must still be compared. A large copy is expensive to compare.@targetis stored in the other file, as a path in the linking file; that file must be writable, and only one linking file can set it.5. Five levels of terms
Before
nxdl.xsd, an element of an NXDL file, an item of a class, part of a data file, or a feature of HDF5. That is how the XML attributeinterpretationof the NXDL field was read as if it defined the NeXus attribute@interpretation.After
A new section, Design > Terms at five levels, names each level once, for example for "attribute":
nxdl.xsd)<xs:element name="attribute"/>.nxdl.xml)<attribute name="units"/>/NXentry/NXdata/data@units/entry/data/data@units="eV"Each level defines or uses a vocabulary (the names and values that may be written), a grammar (how they may be combined: inside what, how often) and semantics (what it means):
nxdl.xsduses those of XSD, and declares the vocabulary and grammar of NXDL. It declares no semantics: the manual gives the semantics of NXDL, in prose.The text this PR touches in the manual, the examples and
nxdl.xsdsays the level of these words. Older text elsewhere still uses synonyms such as "data item".To decide
Other changes
NXdata:@primary(deprecated) is defined onAXISNAME, next to@axis.@NX_classwith its obligatory value and thefieldAttributes, and give the target of a NeXus link as "target:" instead of "suggested target:".nxdl.xsdpage shows XML attributes as "XML attribute name" instead of "@name", since@marks a NeXus or content attribute.nameType="any"means any name that no other NeXus item of the same NeXus group defines: a specified name takes precedence.FIELDNAME_errors".writer_2_1.mnow writes@target.Compatibility
nxdl.xsdonly gains the declarations of the optionalfieldAttributesand the optionalvalueFrom.@NX_class, if a content field whose NeXus field has a units category has no@units, or if the content field or group that a NeXus link describes and the one its target describes do not have the same shared content.Follow-ups, not in this PR
NXrootandNXobject#1672: a common base class forNXrootandNXobject, instead of the copy inNXroot.signal,axes,axisandprimaryof the NXDL field (81 NXDL fields in 27 NXDL files) to NXDL attributes.sameAsof NXDL fields and groups #1671: replace the NXDL link with an XML attributesameAsof NXDL fields and groups.NXimage,NXspectrum,NXellipsometry,NXreflections,NXoptical_spectroscopy,NXmpes_arpes,NXxpcs,NXdelocalization.