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

removed unused namespace prefixes xs and ns #1372

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

woutdenolf
Copy link
Contributor

@woutdenolf woutdenolf commented Mar 9, 2024

Closes #1371

@phyy-nx
Copy link
Contributor

phyy-nx commented Mar 11, 2024

Feel like I should chime in since it touches NXdetector_channel, but dunno enough about namespaces to help :)

@woutdenolf woutdenolf force-pushed the 1371-nxdetector-and-nxdetector_channel-define-redundant-namespace-prefixes branch from 0109e68 to 807ec76 Compare March 13, 2024 10:02
@woutdenolf
Copy link
Contributor Author

woutdenolf commented Mar 13, 2024

Feel like I should chime in since it touches NXdetector_channel, but dunno enough about namespaces to help :)

I'm not a specialist either, but this is what I understand: whenever you use an element from a schema (like NXDL or XSD) in an XML file, you need to specify which XML schema defines that element (i.e. which namespace). This is done by prefixing

<myprefix:parent_element xmlns:myprefix="http://some/url">

    <myprefix:some_schema_element ...>
       ...
    </myprefix:some_schema_element>

</myprefix:parent_element>

The word "myprefix" only matters in this file. You could use another word to refer to the same namepace in other files.

In case you use elements from more than one schema

<myprefix1:parent_element xmlns:myprefix1="http://some/url1" xmlns:myprefix2="http://some/url2">

    <myprefix1:some_schema1_element ...>
       ...
    </myprefix1:some_schema1_element>

    <myprefix2:some_schema2_element ...>
       ...
    </myprefix2:some_schema2_element>

</myprefix1:parent_element>

You can also specify a default namespace which allows you to omit prefixes

<parent_element xmlns="http://some/url">

    <some_schema_element ...>
       ...
    </some_schema_element>

</parent_element>

In all our .nxdl.xml files we obviously use NXDL as the default namespace

<definition
    xmlns="http://definition.nexusformat.org/nxdl/3.1"
>
   <doc ...>
      ...
   </doc>
   <field ...>
      ...
   </field>
</definition>

We could have done this but that would be unnecessary verbose

<nxdl:definition
    xmlns:nxdl="http://definition.nexusformat.org/nxdl/3.1"
>
   <nxdl:doc ...>
      ...
   </nxdl:doc>
   <nxdl:field ...>
      ...
   </nxdl:field>
</nxdl:definition>

Now in NXdetector.nxdl.xml and NXdetector_channel.nxdl.xml we define

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

So we use NXDL as the default namespace as usual but then we define two other prefixes: xs refers XSD (which is the schema used the define the NXDL schema itself) and ns which refers to a particular NXDL version. Neither of these prefixes out used in NXdetector.nxdl.xml and NXdetector_channel.nxdl.xml. Moreover it adds confusion to people like me how are not very familiar with XML schema's. So I propose to remove them.

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 this pull request may close these issues.

NXdetector and NXdetector_channel define redundant namespace prefixes
2 participants