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

NXdetector and NXdetector_channel define redundant namespace prefixes #1371

Open
woutdenolf opened this issue Mar 9, 2024 · 3 comments · May be fixed by #1372
Open

NXdetector and NXdetector_channel define redundant namespace prefixes #1371

woutdenolf opened this issue Mar 9, 2024 · 3 comments · May be fixed by #1372

Comments

@woutdenolf
Copy link
Contributor

woutdenolf commented Mar 9, 2024

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>
  • xmlns:xs: elements and data types with prefix xs that are used in this schema come from this namespace
  • targetNamespace: elements defined by this schema come from this namespace.
  • xmlns:nx: elements and data types with prefix nx that are used in this schema come from this namespace
# 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>
  • xmlns:nxdl: elements and data types with prefix nxdl that are used in this schema come from this namespace

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>
  • xmlns: elements and data types without prefix that are used in this schema come from this namespace (i.e. the default namespace)
  • xmlns:xsi: elements and data types with prefix xs that are used in this schema come from this namespace
  • xsi:schemaLocation: namespace and the location of the XML schema to use for that namespace

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@"
            >
  • xmlns:xs: elements and data types with prefix *xs that are used in this schema come from this namespace
  • xmlns:ns: elements and data types with prefix ns that are used in this schema come from this namespace

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

@woutdenolf woutdenolf linked a pull request Mar 9, 2024 that will close this issue
@woutdenolf woutdenolf linked a pull request Mar 9, 2024 that will close this issue
@prjemian
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants