[yelp-xsl] Consolidate some MathML stuff
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp-xsl] Consolidate some MathML stuff
- Date: Wed, 14 Nov 2012 04:35:47 +0000 (UTC)
commit 1a4157e363f02541866d40ef8ddcb76c04d05393
Author: Shaun McCance <shaunm gnome org>
Date: Tue Nov 13 22:23:42 2012 -0500
Consolidate some MathML stuff
xslt/common/html.xsl | 35 +++++++++++++++++++++++----
xslt/mallard/html/mal2html-math.xsl | 45 ++++++++++++++---------------------
xslt/mallard/html/mal2html.xsl | 6 ++--
3 files changed, 51 insertions(+), 35 deletions(-)
---
diff --git a/xslt/common/html.xsl b/xslt/common/html.xsl
index 5ac785c..6c0beb3 100644
--- a/xslt/common/html.xsl
+++ b/xslt/common/html.xsl
@@ -18,12 +18,12 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:exsl="http://exslt.org/common"
xmlns:set="http://exslt.org/sets"
xmlns:its="http://www.w3.org/2005/11/its"
xmlns="http://www.w3.org/1999/xhtml"
- exclude-result-prefixes="html math set its"
+ exclude-result-prefixes="html mml set its"
extension-element-prefixes="exsl"
version="1.0">
@@ -114,6 +114,28 @@ using #{xsl:element}.
<!--@@==========================================================================
+html.mathml.namespace
+The XML namespace for the output document.
+:Revision:version="3.8" date="2012-11-13" status="final"
+
+This parameter specifies the XML namespace for MathML in output documents. It
+will be set automatically based on the ${html.xhtml} parameter, either to the
+MathML namespace namespace, or to the empty namespace. Stylesheets can use this
+parameter when using #{xsl:element}.
+-->
+<xsl:variable name="html.mathml.namespace">
+ <xsl:choose>
+ <xsl:when test="$html.xhtml">
+ <xsl:value-of select="'http://www.w3.org/1998/Math/MathML'"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text></xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+
+
+<!--@@==========================================================================
html.extension
The filename extension for all output files.
:Revision:version="1.0" date="2010-05-25" status="final"
@@ -1538,14 +1560,17 @@ output relative to @{html.js.root}.
<!--**==========================================================================
html.js.mathjax
Output #{script} element to include MathJax.
-:Revision: version="1.0" date="2012-11-13" status="incomplete"
+:Revision: version="1.0" date="2012-11-13" status="final"
$node: The node to create JavaScript for.
-FIXME
+This template outputs an HTML #{script} tag to reference MathJax. It only
+outputs a #{script} element if ${node} has MathML descendent content. By
+default, this template uses #{cnd.mathjax.org}. If you wish to use a local
+copy, override this template and provide the necessary files.
-->
<xsl:template name="html.js.mathjax">
<xsl:param name="node" select="."/>
- <xsl:if test="$node//math:*[1]">
+ <xsl:if test="$node//mml:*[1]">
<script type="text/javascript">
<xsl:attribute name="src">
<xsl:text>http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_HTMLorMML</xsl:text>
diff --git a/xslt/mallard/html/mal2html-math.xsl b/xslt/mallard/html/mal2html-math.xsl
index c83a1d1..b46ca22 100644
--- a/xslt/mallard/html/mal2html-math.xsl
+++ b/xslt/mallard/html/mal2html-math.xsl
@@ -18,50 +18,39 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mal="http://projectmallard.org/1.0/"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/1999/xhtml"
- exclude-result-prefixes="mal math xlink"
+ exclude-result-prefixes="mal mml xlink"
version="1.0">
<!--!!==========================================================================
Mallard to HTML - MathML
-Handle embedded MathML.
+Handle MathML in Mallard documents.
:Revision: version="3.8" date="2012-11-13" status="final"
This stylesheet matches embedded MathML in %{mal2html.block.mode} and
%{mal2html.inline.mode} and processes it in %{mal2html.math.mode}. The
-matched templates for the #{math:math} element automatically set the
+matched templates for the #{mml:math} element automatically set the
#{display} attribute based on whether the element is in block or inline
context.
-->
-<xsl:variable name="math.namespace">
- <xsl:choose>
- <xsl:when test="$html.namespace = 'http://www.w3.org/1999/xhtml'">
- <xsl:text>http://www.w3.org/1998/Math/MathML</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text></xsl:text>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:variable>
-
-
<!--%%==========================================================================
mal2html.math.mode
-Output MathML and handle Mallard extension.
+Output MathML and handle Mallard extensions.
:Revision: version="3.8" date="2012-11-13" status="final"
This mode is used for processing MathML embedded into Mallard documents. For
-most types of MathML content, it simply copies the input directly. It checks
-for Mallard linking using the #{mal:xref} attribute and transforms this to a
-MathML #{href} attribute. It also converts #{xlink:href} attributes from
-MathML 2 to #{href} attributes for MathML 3.
+most types of MathML content, it simply copies the input directly, except it
+outputs the MathML in a way that allows the namespace to stripped for non-XML
+output. It checks for Mallard linking using the #{mal:xref} attribute and
+transforms this to a MathML #{href} attribute. It also converts #{xlink:href}
+attributes from MathML 2 to #{href} attributes for MathML 3.
-->
-<xsl:template mode="mal2html.math.mode" match="math:*">
- <xsl:element name="{local-name(.)}" namespace="{$math.namespace}">
+<xsl:template mode="mal2html.math.mode" match="mml:*">
+ <xsl:element name="{local-name(.)}" namespace="{$html.mathml.namespace}">
<xsl:for-each select="@*[name(.) != 'href']">
<xsl:copy-of select="."/>
</xsl:for-each>
@@ -91,7 +80,9 @@ MathML 2 to #{href} attributes for MathML 3.
<xsl:value-of select="."/>
</xsl:template>
-<xsl:template mode="mal2html.block.mode" match="math:math">
+<xsl:template mode="mal2html.math.mode" match="*"/>
+
+<xsl:template mode="mal2html.block.mode" match="mml:math">
<xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
<div>
<xsl:call-template name="html.lang.attrs"/>
@@ -102,7 +93,7 @@ MathML 2 to #{href} attributes for MathML 3.
<xsl:value-of select="$if"/>
</xsl:if>
</xsl:attribute>
- <xsl:element name="math" namespace="{$math.namespace}">
+ <xsl:element name="math" namespace="{$html.mathml.namespace}">
<xsl:for-each select="@*[name(.) != 'display']
[not(starts-with(namespace-uri(.), 'http://projectmallard.org/'))]">
<xsl:copy-of select="."/>
@@ -116,10 +107,10 @@ MathML 2 to #{href} attributes for MathML 3.
</xsl:if>
</xsl:template>
-<xsl:template mode="mal2html.inline.mode" match="math:math">
+<xsl:template mode="mal2html.inline.mode" match="mml:math">
<span class="math">
<xsl:call-template name="html.lang.attrs"/>
- <xsl:element name="math" namespace="{$math.namespace}">
+ <xsl:element name="math" namespace="{$html.mathml.namespace}">
<xsl:for-each select="@*[name(.) != 'display']
[not(starts-with(namespace-uri(.), 'http://projectmallard.org/'))]">
<xsl:copy-of select="."/>
diff --git a/xslt/mallard/html/mal2html.xsl b/xslt/mallard/html/mal2html.xsl
index 198c738..40b33fc 100644
--- a/xslt/mallard/html/mal2html.xsl
+++ b/xslt/mallard/html/mal2html.xsl
@@ -18,8 +18,8 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- exclude-result-prefixes="html math"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ exclude-result-prefixes="html mml"
version="1.0">
<!--!!==========================================================================
@@ -39,6 +39,6 @@ sets @{html.xhtml} to #{false} and @{mal.if.target} to #{'target:html'}.
<xsl:include href="mal2xhtml.xsl" pass="true"><?pass?></xsl:include>
<xsl:namespace-alias stylesheet-prefix="html" result-prefix="#default"/>
-<xsl:namespace-alias stylesheet-prefix="math" result-prefix="#default"/>
+<xsl:namespace-alias stylesheet-prefix="mml" result-prefix="#default"/>
</xsl:stylesheet>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]