-
Notifications
You must be signed in to change notification settings - Fork 56
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
nxdlTypes: invalid XML schema #1368
Comments
This was created in #592 to make the unit examples machine readable. Unfortunately this is not a valid XML schema: https://www.w3schools.com/xml/el_documentation.asp |
Thanks. Mea culpa. I'll look at it later today.
…On Sun, Mar 3, 2024, 8:49 AM Wout De Nolf ***@***.***> wrote:
This was create in #592
<#592> to make the unit
example machine readable. Unfortunately this is not a valid XML schema:
https://www.w3schools.com/xml/el_documentation.asp
—
Reply to this email directly, view it on GitHub
<#1368 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARMUMHN6DJOPZX22ZGW3ZLYWM2ALAVCNFSM6AAAAABED7TLG2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZVGE4DMNZZHE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
At issue here is the use of Lines 87 to 95 in 4c09c77
The intent of PR #592:
The examples should be re-factored to make the XML Schema file valid, yet allow the units to be machine-readable. |
@woutdenolf : Why are you convinced the XML Schema file The XML Schema files ( definitions/dev_tools/tests/test_nxdl.py Line 30 in 4c09c77
definitions/dev_tools/nxdl/syntax.py Line 23 in 4c09c77
definitions/dev_tools/nxdl/syntax.py Line 12 in 4c09c77
https://github.com/nexusformat/definitions/blob/4c09c7718c41dc90eb996475efdf1c0d30fb1d5d/dev_tools/globals/directories.py#L40C30-L40C44 definitions/dev_tools/globals/directories.py Line 116 in 4c09c77
When I load this file into a XML Schema editor in a new installation of the eclipse IDE (eclipse.org), the validator for such XML Schemas does not show any errors on these The W3Schools page you referenced state that a
|
On the Would it help to add an additional attribute of <xs:element name="example">m^2</xs:element>
<xs:element name="example">barns</xs:element> would change to <xs:element name="example" type="xs:string">m^2</xs:element>
<xs:element name="example" type="xs:string">barns</xs:element> |
Adding
Also using import xmlschema
xmlschema.XMLSchema11("nxdl.xsd") I believe we are using
"Convinced" is a strong word. The validator I used said
I did not understand what that meant. |
What about Well-formed XML content adheres to the XML standard:
Valid XML means additional rules must be met. Valid XML must adhere to the DTD or schema. In this case, it is the schema for XML Schema files. |
With Thanks for looking into this @prjemian ! |
Their example suggested the root cause to me. In their example, which produced the same error message, the problem was produced from the As I understand it, |
It turns out to be an error in the validator ( |
Thanks for testing our foundation structures! |
In fact there is a problem as pointed out here: sissaschool/xmlschema#390 (comment) It is not |
A suggestion at today's telco was to define an Keep in mind the goal is to provide machine readable example(s) for each of the unit types. The Python code that creates documentation for each of the NXDL classes is the first consumer of these examples. The NeXusOntology is another potential consumer of these examples. |
Whatever suggested remedies to this issue should be tested with both the |
Just to add some further thoughts: The stated goal here is to provide information that is machine actionable; i.e., not for human consumption. This is rather at odds with the definition of XML Schema also supports I'm also wondering if these "examples" are really doing more work than providing examples of valid units. Perhaps these are really intended to provide canonical representations of specific units. For example, providing the example "angstrom" suggests that the unit attribute is written Such a list of canonical forms would be an open enumeration (other units are still accepted). We would want to document the canonical form for certain well-known units. Also, using a non-canonical form might trigger a warning by a validator (as hinted by the pull-request) Such a list of canonical forms might be defined through an <xs:simpleType name="NX_WAVELENGTH">
<xs:annotation>
<xs:documentation>units of wavelength</xs:documentation>
<xs:appinfo>
<nxdl-def:values>
<nxdl-def:value>angstrom</nxdl-def>
<nxdl-def:value>nanometre</nxdl-def>
</nxdl-def:values>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string"/>
</xs:simpleType> However, since this is really just an enumeration. We could define the values using standard XML Schema terms; for example: <xs:simpleType name="NX_WAVELENGTH">
<xs:annotation>
<xs:documentation>units of wavelength</xs:documentation>
</xs:annotation>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value='angstrom'>
<xs:annotation>
<xs:documentation>The non-SI unit equivalent to 10^-10 meters</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value='nanometre'>
<xs:annotation>
<xs:documentation>The SI unit equivalent to 10^-9 meters</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:annotation>
<xs:documentation>Non-canonical unit. Please register with NIAC.</xs:documentation>
<xs:appinfo>
<nxdl-def:warn>Non canonical unit</nxdl-def:warn>
</xs:appinfo>
<xs:annotation>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType> The documentation could then auto-generate the list of canonical representations for units (along with human readable descriptions). It might be possible for a validator could issue a warning if a non-canonical form is used. |
The text was updated successfully, but these errors were encountered: