w3c / w3c/mathml

XSD not allowing <semantics>-element as child of <apply>-element

Open
#498 4 comments 0 reactions 1 assignee View on GitHub

@davidcarlisle is already working on this.

Since Jul 1, 2024.

MathML 4 need specification update
Dominant language
HTML
Stars
82
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Dear maintainers,

thank you very much for providing MathML and taking care of it!

I want to semantically annotate operators in a formula, which seems to be a perfect use-case for the <semantics>-element. A minimal working example (MWE) for my application is very similiar to the last example of subsection 4.2.1.3:

mathml_mwe.xml:

<math xmlns="http://www.w3.org/1998/Math/MathML">
    <apply>
        <semantics>
            <csymbol id="operation">OP</csymbol>
            <annotation>OPERATOR</annotation>
        </semantics>
        <semantics>
            <ci id="input">x</ci>
            <annotation>INPUT</annotation>
        </semantics>
    </apply>
</math>

However, if I validate either the MWE or the mentioned example in the documentation against the XSD, both result in (something like) this:

failed validating <Element '{http://www.w3.org/1998/Math/MathML}apply' at 
0x00000219EFDF6ED0> with XsdGroup(model='sequence', occurs=[1, 1]):

Reason: Unexpected child with tag 'm:semantics' at position 1.

Similiar errors arise, if only the <csymbol>-element or the <ci>-element is semantically annotated. It seems, like the schema does not allow a <semantics>-child inside an <apply>-element. My questions are therefore: Is this behaviour intended? Am I using the <semantics>-element in a wrong way? Might this be a problem with my validation script? Or does the schema need an adjustment?

Best regards
Maximilian


I am validating using Python and xmlschema as follows:

mathml_validate.py:

import os
import xmlschema

mathml_object = os.path.abspath("mathml_mwe.xml")
mathml_schema_path = "https://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd"

try:
    schema = xmlschema.XMLSchema(mathml_schema_path)
    result = schema.validate(mathml_object)
    print(result)
except Exception as e:
    print(f"Schema did not validate successfully. (Error: {e})")

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.