Hi Richard, El 22/07/24 a las 3:11, Richard Sent escribió:
Hi all,I have some XML created by a tool called latexml that can convert LaTeX equations to MathML. I am processing the output of this tool as part of a Guile program and will be using it in a website. The output looks something like this: --8<---------------cut here---------------start------------->8--- <math xmlns=\"http://www.w3.org/1998/Math/MathML\" alttext=\"\\frac{1}{2}\" display=\"block\"> <mfrac> <mn>1</mn> <mn>2</mn> </mfrac> </math> --8<---------------cut here---------------end--------------->8--- I need to convert this output to SXML to integrate it with the rest of the toolchain. Annoyingly, when using xml->sxml, the xmlns attribute is prepended to every non-default element. For example, '(http://www.w3.org/1998/Math/MathML:math ...) [1]. This behavior is undesirable when splicing the MathML into HTML, since HTML doesn't support namespaces and web browsers don't seem to handle elements with colons. The intended conversion is to simply splice the MathML into HTML, sans namespace [2]. xml->sxml has a #:namespaces argument that allows me to alias the URL namespace to something else in the SXML, but it doesn't look like I can alias it to a "nil" namespace that isn't prepended at all.
The following seems to work (where xml-string is the example you provided): (define namespaces '((#false . "http://www.w3.org/1998/Math/MathML"))) (xml->sxml xml-string #:namespaces namespaces)$7 = (*TOP* (math (@ (display "block") (alttext "\\frac{1}{2}")) "\n " (mfrac "\n " (mn "1") "\n " (mn "2") "\n ") "\n"))
OpenPGP_0x0AB0D067012F08C3.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature