Bug 152851 - MathML import should work even when no xmlns attribute is present
Summary: MathML import should work even when no xmlns attribute is present
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
7.4.3.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Formula-Editor MathML
  Show dependency treegraph
 
Reported: 2023-01-02 23:19 UTC by Philippe
Modified: 2023-01-05 17:05 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe 2023-01-02 23:19:13 UTC
Description:
In Html5 <math> tags can be found without the attribute xmlns="http://www.w3.org/1998/Math/MathML". It would make sense if we could import such mathml into LO ( At the moment it's not working at all). 

Steps to Reproduce:
Go to eg. https://developer.mozilla.org/en-US/docs/Web/MathML/Examples, select an example (let say Pythagorean Theorem) and using you browser's "inspect" contextual menu (in Firefox or Chromium/Chrome, at least), select a <math> tag representing a formula and Copy it. It gives :
<math>
    <mrow>
      <msup>
        <mi>a</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <msup>
        <mi>b</mi>
        <mn>2</mn>
      </msup>
      <mo>=</mo>
      <msup>
        <mi>c</mi>
        <mn>2</mn>
      </msup>
    </mrow>
  </math>

 Then in LO formula editor try "Tools-> Import Mathml from clipboard"

Actual Results:
Nothing is pasted. Import from file would not work either.


Expected Results:
The selected tag has no xmlns attribute, yet it is perfectly valid Mathml (in the context of html5 which is everywhere now) and should pose no problem of interpretation.

The absence of xmlns attribute in <math> should not prevent import; Requiring its presence seems an artificial limit, and I see no good reason for it.


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 7.4.3.2 / LibreOffice Community
Build ID: 40(Build:2)
CPU threads: 4; OS: Linux 6.0; UI render: default; VCL: gtk3
Locale: fr-FR (fr_FR.UTF-8); UI: en-US
Debian package version: 1:7.4.3-2
Calc: threaded
Comment 1 V Stuart Foote 2023-01-03 17:04:19 UTC
I don't think this would be appropriate. The XML Namespace (xmlns:) is significant to sm parsing as it declares the syntax of the content, and then for correctly holding its source in the resulting ODF archive.   

For example if we eventually were to extend the import filter parsing to include TeX / LaTeX (bug 96208), or maybe AsciiMath markups--the import parsers have to be able to identify the source formatting.

The prescribed xmlns: for MathML flags this cleanly for clipboard import of MathML, it is needed to validate content.
Comment 2 Heiko Tietze 2023-01-04 07:57:50 UTC
The RELAX NG schema, and I believe we are talking about this, has been introduced a while ago and we should support it. What do you think, Regina?
Comment 3 V Stuart Foote 2023-01-04 13:43:23 UTC
(In reply to Heiko Tietze from comment #2)
> The RELAX NG schema, and I believe we are talking about this, has been
> introduced a while ago and we should support it. What do you think, Regina?

Looks to me that RELAX NG still requires a DTD of the xmlns: tag for the content.
Comment 4 Regina Henschel 2023-01-04 14:51:26 UTC
I think, it is a valid enhancement request. It might be duplicate to bug 98827, at least strong related. From a user point of view such feature is important as it would allow to import <math> fragments. I would restrict the request to texts, which have <math> root element and start with <math>. The result might not be as expected because LibreOffice's MathML support is at version 2.0. But getting something the user then can edit is better than getting nothing.
Comment 5 Ben van der Merwe 2023-01-05 17:05:49 UTC
Regina, I think this is the same as bug 98827 which I logged. If you look in that bug, the xlmns in

<math xmlns="http://www.w3.org/1998/Math/MathML">

is definitely optional and going forward with HTML5 will be seen less.

It should be a simple fix, if you get <math>, assume it implies <math xmlns="http://www.w3.org/1998/Math/MathML">

This should be safe, because if LibeOffice just gets <math> it does not understand it and can do nothing. So you don;t lose anything by doing that...