Hi all,
I have an HTML5-namespaced document containing MathML-namespaced <math> content:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Equations</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mspace/>
</mrow>
</math>
</body>
</html>
I am trying to create an XSLT transformation that modifies these islands of
MathML while leaving the surrounding content untouched. As a test, I try
wrapping <mspace> elements in <mrow>:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xpath-default-namespace="http://www.w3.org/1998/Math/MathML"
exclude-result-prefixes="xs"
version="2.0">
<!-- baseline identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- xpath-default-namespace is the MathML namespace -->
<xsl:template match="mspace">
<mrow>
<xsl:copy-of select="."/>
</mrow>
</xsl:template>
</xsl:stylesheet>
However, the output has namespace references that are redundant with their
enclosing context:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Equations</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mrow xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns="">
<mspace xmlns="http://www.w3.org/1998/Math/MathML"/>
</mrow>
</mrow>
</math>
</body>
</html>
I've been reading about XSLT and namespaces for hours. This is the best
resource I've found:
http://www.lenzconsulting.com/namespaces-in-xslt/
and it got me to this point. My questions are:
1. Why would the XSLT serializer write explicit namespace references that
aren't needed by context?
1. Isn't the point of namespaces that everything is fully qualified
internally, then the output can adjust accordingly?
1. How do I get a clean <math> island of MathML content without namespace
stuff cluttering up its contents?
Thanks in advance!
-----
Chris Papademetrious
Tech Writer, Implementation Group
(610) 628-9718 home office
(570) 460-6078 cell
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--