Ich tippe ein Buch mit mathematischen Formeln, die in MathML geschrieben wurden. Das Buch hat eine "Haupt" XML-Datei, die alle Kapitel Dateien wie diese enthält:DocBook 5, Hinzufügen (MathML) Namespace zu HTML-Ausgabe?
<?xml version="1.0" encoding="utf-8"?>
<book xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.1"
xml:lang="en">
<title>Some title</title>
<xi:include href="intro.xml"/>
</book>
Und intro.xml geht als
<?xml version="1.0" encoding="utf-8"?>
<chapter xml:id="ch-intro" xmlns:m="http://www.w3.org/1998/Math/MathML">
<title>Introduction</title>
<para>Some text
<inlineequation>
<m:math><m:msqrt><m:mi>a</m:mi></m:msqrt></m:math>
</inlineequation>
Some other text.
</para>
</chapter>
Das ist etwas wie
<p>Some text
<m:math xmlns:m="http://www.w3.org/1998/Math/MathML">
<m:msqrt><m:mi>a</m:mi></m:msqrt>
</m:math>
Some other text.</p>
I produziert haben Sie eine Anpassungsschicht XSLT über dem HTML XSLT von Docbook-XSL, um MathJax zu laden:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://www.w3.org/1998/Math/MathML"
version="1.0">
<xsl:import href="docbook-xsl-nons-snapshot/html/docbook.xsl"/>
<!-- Add MathJax <script> tags to document <head> -->
<xsl:template name="user.head.content">
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=MML_CHTML"></script>
</xsl:template>
</xsl:stylesheet>
Und das funktioniert in dem Sinne, dass es das <script>
Tag zu hinzufügt, aber MathJax rendert die Formel nicht, da es nicht funktioniert, wenn der MathML-Namespace auf <math>
selbst ist. Der Namespace muss zu gehen.
Also meine Frage ist, wie soll ich die XSLT-Anpassungsschicht schreiben, um xmlns:m="http://www.w3.org/1998/Math/MathML"
zu dem generierten -Tag hinzuzufügen?
Das funktioniert super! Es ließ auch jedes nicht das Attribut xmlns: m haben. Vielen Dank! –
MetroWind