nexusformat / definitions

Definitions of the NeXus Standard File Structure and Contents
https://manual.nexusformat.org/
Other
26 stars 55 forks source link

NXdetector and NXdetector_channel define redundant namespace prefixes #1371

Open woutdenolf opened 4 months ago

woutdenolf commented 4 months ago

The definition xmlns:xs and xmlns:ns attributes in NXdetector and NXdetector_channel are not used and therefore redundant. As I'm not that familiar with XML schema's, here is why I think so:

Schema's

NXDL schema attributes (https://www.w3schools.com/xml/schema_schema.asp)

# nxdl.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://definition.nexusformat.org/nxdl/3.1"
    xmlns:nx="http://definition.nexusformat.org/nxdl/3.1"
    ...>
    ...
</xs:schema>
# nxdlTypes.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://definition.nexusformat.org/nxdl/3.1"
    xmlns:nxdl="http://definition.nexusformat.org/nxdl/3.1"
    ...>
    ...
</xs:schema>

To harmonize we should probably choose one prefix for the NXDL namespace: xmlns:nx or xmlns:nxdl.

Definitions

Most definitions have these attributes

# base_classes/NXentry.nxdl.xml

<definition ...
    xmlns="http://definition.nexusformat.org/nxdl/3.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd"
    >
    ...
</definition>

However NXdetector and NXdetector_channel have these attributes

# base_classes/NXdetector.nxdl.xml

<definition ...
            xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd"
            xmlns="http://definition.nexusformat.org/nxdl/3.1"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:ns="http://definition.nexusformat.org/nxdl/@NXDL_RELEASE@"
            >

There is no harm in doing so but the prefix xs and ns are not used so these are redundant.

prjemian commented 3 months ago

I'm ok with removing unused namespaces. Are we certain there are no consequences for child content (such as other base classes)? I do not believe that to be a problem. Each NXDL file is self-contained in its declaration of namespaces.

woutdenolf commented 3 months ago

The ns: prefix is not uses anywhere. The xs: prefix is only used in the NXDL schema definition itself, not in the nxdl files, which would conceptually be strange anyway, which why I propose the remove it to avoid confusion.

woutdenolf commented 3 months ago

Also, prefixes only exist locally inside one XML file so they cannot affect other XML files.