Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for open enumerations #1521

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 166 additions & 1 deletion base_classes/NXobject.nxdl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,170 @@
This is the base object of NeXus
</doc>
<!--attribute name="name"><doc>name of instance</doc></attribute-->
</definition>
<field name="identifierNAME" type="NX_CHAR" nameType="partial">
<doc>
An identifier for a (persistent) resource.

An identifier, provided by some authority, that has been assigned to the
real-world object described by this ``NXobject``. To be useful, the identifier
must not be reassigned to a different real-world object. It is typical for
there to be some mechanism to resolve an identifier, obtaining metadata
about the object. Identifiers for which some guarantees exist regarding
this resolution process are called persistent identifiers.
Persistent identifiers are also known as PIDs.
</doc>
<attribute name="type" type="NX_CHAR">
<doc>
The type of identifier used.

It is recommended to use the most specific type when describing the identifier.

For example, all IGSNs are DOIs and all DOIs are Handles; however, an IGSN should have type IGSN (and not DOI or Hdl).
Similarly, an ARK, Purl, ORCID and ROR identifiers should have their corresponding types and should not use the more generic URL identifier.
</doc>
<enumeration open="true">
<item value="ARK">
<doc>
Archival Resource Key.

An ARK is a Uniform Resource Identifier (URI) designed to support long-term access to a variety of information objects.

Syntax: https://NMA/ark:/NAAN/Name[Qualifier]. Brackets indicate optional elements.
Example: https://example.org/ark:/12345/abcde
</doc>
</item>
<item value="DOI">
<doc>
Digital Object Identifier.

A DOI is a unique alphanumeric string used to identify digital content. It consists of a prefix and a suffix, separated by a slash.

Syntax: 10.XXXX/XXXXXX
Example: 10.1107/S1600576714027575
</doc>
</item>
<item value="Hdl">
<doc>
A handle is a unique identifier that consists of a prefix indicating the naming authority and a suffix representing the local name
of a resource, cts.

A handle is a unique identifier used to facilitate the identification and management of digital objects. It is composed of a prefix that
indicates the naming authority and a suffix that specifies the resource's local name.

This refers specifically to an ID in the Handle system operated by the Corporation for National Research Initiatives (CNRI).

Syntax: prefix/identifier
Example: 123456789/abc123
</doc>
</item>
<item value="IGSN">
<doc>
International Generic Sample Number.

The IGSN is a unique identifier assigned to a specific sample or specimen in the context of scientific research.

Since 2021, IGSNs are issued by DataCite, meaning that there are now DataCite-issued DOIs for all IGSNs,
including those historical IGSNs issued beforehand. Therefore, the syntax is the same as for DOIs.

Syntax: 10.XXXX/XXXXXX
Example: 10.1107/S1600576714027575
</doc>
</item>
<item value="ISNI">
<doc>
ISNI is an ISO standard to uniquely identify individuals and organizations involved in creative work, including pseudonyms
and other public personas.

An ISNI-ID is made up of 16 digits, the last character being a check character. The check character may be either a decimal digit
or the character “X”.

A URL can be generated from the ISNI ID by combining it with the prefix https://isni.org/isni/, resulting in
https://isni.org/isni/{ISNI-ID}.

Syntax: 16 base-10 digits stored without any spaces.
Example: 0000000121032683
</doc>
</item>
<item value="ISSN">
<doc>
International Standard Serial Number

An ISSN is an 8-digit unique identifier used to distinguish a serial publication, whether in print or electronic form.
The last character (a digit or 'X') serves as a check character, making the ISSN uniquely defined by its first seven digits.

Syntax: NNNN-NNNC, where N a decimal digit character (i.e., in the set {0,1,2,...,9}), and C is in {0,1,2,...,9,X}
Example: 1234-5678 or 1234-567X
</doc>
</item>
<item value="ISSN-L">
<doc>
Linking ISSN

The linking The ISSN, or ISSN-L, is a specific ISSN that groups the different media of the same serial publication.

Syntax: NNNN-NNNC, where N a decimal digit character (i.e., in the set {0,1,2,...,9}), and C is in {0,1,2,...,9,X}
Example: 1234-5678 or 1234-567X
</doc>
</item>
<item value="ORCID">
<doc>
Open Researcher and Contributor identifier.

ORCID provides a free and persistent identifier that uniquely distinguishes authors and contributors in scientific research.

Syntax: https://orcid.org/XXXX-XXXX-XXXX-XXXX
Example: https://orcid.org/0000-0002-1825-0097
</doc>
</item>
<item value="PURL">
<doc>
Persistent Uniform Resource Locator.

A Persistent Uniform Resource Locator (PURL) is a type of URL designed to provide a stable, long-term reference to a web
resource by using a resolver to redirect users to the resource's current location, even if it moves over time.

A PURL has three parts: (1) a protocol, (2) a resolver address, and (3) a name.

Syntax: https://purl.org/foo/bar
Example: https://purl.org/dc/elements/1.1/title
</doc>
</item>
<item value="ROR">
<doc>
Research Organization Registry

A ROR ID is a globally unique identifier for research organizations, enabling unambiguous linking of institutions across systems.

Syntax: https://ror.org/{ROR-ID}
Example: https://ror.org/052gg0110
</doc>
</item>
<item value="URL">
<doc>
Uniform Resource Locator

Also known as web address, a URL is the address used to access a resource on the internet,
specifying its location and the protocol to retrieve it.

Syntax: scheme://domain:port/path?query_string#fragment_id
Example: https://www.example.com/about
</doc>
</item>
<item value="URN">
<doc>
Uniform Resource Name

A URN is a unique, persistent identifier for a resource regardless of where it is stored.

It is recommended that identifiers with more specific type attribute (such as DOI or ISSN) values should not be stored as a URN,
even when this is valid. As an example, the URN doi:10.1107/S1600576714027575 is a valid URN-based representation for the DOI
10.1107/S1600576714027575, but it is recommended to use type="DOI" in this case.

Syntax: urn:&lt;namespace&gt;:&lt;namespace-specific-string&gt;. The leading urn: sequence is case-insensitive.
Example: urn:isbn:0000000000000
</doc>
</item>
</enumeration>
</attribute>
</field>
</definition>
2 changes: 1 addition & 1 deletion base_classes/NXsource.nxdl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</field>
<field name="type">
<doc>type of radiation source (pick one from the enumerated list and spell exactly)</doc>
<enumeration>
<enumeration open="true">
<item value="Spallation Neutron Source" />
<item value="Pulsed Reactor Neutron Source" />
<item value="Reactor Neutron Source" />
Expand Down
12 changes: 9 additions & 3 deletions dev_tools/docs/nxdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,16 @@ def _print_enumeration(self, indent, ns, parent):
if len(node_list) == 0:
return ""

if len(node_list) == 1:
self._print(f"{indent}Obligatory value:", end="")
if parent.attrib.get("open", "false") == "true":
self._print(
f"{indent}This is an open enumeration. Any of these values is suggested:",
end="",
)
else:
self._print(f"{indent}Any of these values:", end="")
if len(node_list) == 1:
self._print(f"{indent}Obligatory value:", end="")
else:
self._print(f"{indent}Any of these values:", end="")

docs = OrderedDict()
for item in node_list:
Expand Down
13 changes: 13 additions & 0 deletions nxdl.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,11 @@ https://stackoverflow.com/a/48980995/1046449 -->

(This data type is used internally in the NXDL schema
to define elements and attributes to be used by users in NXDL specifications.)

Enumerations can be closed or open. A closed enumeration is one where the list of
values are the only ones allowed for a specification. An open enumeration is one
where the list of values is incomplete and additional values other than those listed
are allowed.

::

Expand Down Expand Up @@ -1279,6 +1284,14 @@ https://stackoverflow.com/a/48980995/1046449 -->
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="open" use="optional" type="nx:NX_BOOLEAN" default="false" >
<xs:annotation>
<xs:documentation>
Is this an open enumeration?
An open enumeration allows additional values not listed.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>

<xs:complexType name="dimensionsType">
Expand Down
Loading