[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] MathML and XSL


Subject: Re: [xsl] MathML and XSL
From: Gerard Milmeister <milmei@xxxxxxxxxxxx>
Date: 13 Nov 2002 22:39:12 +0100

On Sat, 2002-11-09 at 22:46, David Carlisle wrote:
> 
> <!ENTITY % mathml PUBLIC "-//W3C//DTD MathML 2.0//EN"
>                   "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">
> %mathml;
> 
> 
> as noted in the mathml errata there's an updated dtd in
> http://www.w3.org/Math/DTD/mathml2/mathml2.dtd
> 
>   <xsl:template match="math">
> the mathml dt dthat you've included will default mathml elements in to
> the mathml namespace so this will need to be
> 
>   <xsl:template match="m:math">
> 
> where m: is bound in the stylesheet to the mathml namespace
> 
> since you just want to copy math and all it's children you can simplify
> what you had to
> 
> 
>   <xsl:template match="m:math">
>    <xsl:copy-of select"."/>
>   </xsl:template>

In the meantime I found the following solution.

<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:m="http://www.w3.org/1998/Math/MathML"
  version="1.0">

  <xsl:template match="m:*">
    <xsl:element name="{name(.)}"
namespace="http://www.w3.org/1998/Math/MathML">
      <xsl:for-each select="@*">
        <xsl:attribute name="{name(.)}">
          <xsl:value-of select="."/>
        </xsl:attribute>
      </xsl:for-each>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

This seems to work and has the advantage that I may create templates for
certain mathml elements when I would need them.
However, your solution may prove useful...

There is however a difference between the output from xalan (in Cocoon)
and xsltproc.
the xalan is as I would expect, however from xsltproc I get the
following:

<math xmlns="http://www.w3.org/1998/Math/MathML"
overflow="scroll"><msqrt xmlns="http://www.w3.org/1998/Math/MathML"><mi
xmlns="http://www.w3.org/1998/Math/MathML">x</mi>+<mi
xmlns="http://www.w3.org/1998/Math/MathML">y</mi></msqrt></math>

that is the namespace is included in every tag. Is this correct
and simply redundant or what?


-- 
Gérard Milmeister
Universität Zürich
Tel: 01-635 45 65
E-Mail: milmei@xxxxxxxxxxxx
Büro: 27-G-35


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread