Skip to content

NXDL: should primitiveType be an enumeration instead of a union? #1638

Description

@woutdenolf

The NXDL schema defines a complexType called fieldType with this attribute

<xs:attribute name="type" type="nx:primitiveType" default="NX_CHAR">

and the type of the type is defined as

<xs:simpleType name="primitiveType">
	<xs:annotation>
		<xs:documentation>any valid NeXus field or attribute type</xs:documentation>
	</xs:annotation>
	<xs:union memberTypes="
		nxdl:ISO8601
		nxdl:NX_BINARY
		nxdl:NX_BOOLEAN
		nxdl:NX_CCOMPLEX
		nxdl:NX_CHAR
		nxdl:NX_COMPLEX
		nxdl:NX_DATE_TIME
		nxdl:NX_FLOAT
		nxdl:NX_INT
		nxdl:NX_NUMBER
		nxdl:NX_PCOMPLEX
		nxdl:NX_POSINT
		nxdl:NX_QUATERNION
		nxdl:NX_UINT
		nxdl:NX_CHAR_OR_NUMBER
		"/>
</xs:simpleType>

and NX_CHAR, NX_INT, ... etc are simple types

<xs:simpleType name="NX_CHAR">
	<xs:annotation>
		<xs:documentation>
			A string of characters. The preferred string encoding is :index:`UTF-8`. 
			This is the default field type.
		</xs:documentation>
	</xs:annotation>
	<xs:restriction base="xs:string" />
</xs:simpleType>

<xs:simpleType name="NX_INT">
	<xs:annotation>
		<xs:documentation>any representation of an integer number</xs:documentation>
	</xs:annotation>
	<xs:restriction base="xs:integer" />
</xs:simpleType>

Some values of the field's type attribute that are valid

XML Why
type="NX_FLOAT" It's a valid string (NX_CHAR).
type="NX_INT" It's a valid string (NX_CHAR).
type="banana" It's also a valid string (NX_CHAR).
type="42" Valid as NX_INT and NX_CHAR.
type="3.14" Valid as NX_FLOAT and NX_CHAR.

I think what NXDL actually intended is this

<xs:simpleType name="primitiveType">
    <xs:restriction base="xs:string">
        <xs:enumeration value="NX_BINARY"/>
        <xs:enumeration value="NX_BOOLEAN"/>
        <xs:enumeration value="NX_CCOMPLEX"/>
        <xs:enumeration value="NX_CHAR"/>
        <xs:enumeration value="NX_COMPLEX"/>
        <xs:enumeration value="NX_DATE_TIME"/>
        <xs:enumeration value="NX_FLOAT"/>
        <xs:enumeration value="NX_INT"/>
        <xs:enumeration value="NX_NUMBER"/>
        <xs:enumeration value="NX_PCOMPLEX"/>
        <xs:enumeration value="NX_POSINT"/>
        <xs:enumeration value="NX_QUATERNION"/>
        <xs:enumeration value="NX_UINT"/>
        <xs:enumeration value="NX_CHAR_OR_NUMBER"/>
        <xs:enumeration value="ISO8601"/>
    </xs:restriction>
</xs:simpleType>

Which essentially means that the simple type definitions NX_CHAR, NX_INT, ... are not actually used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions