#36 Incorrect processing in net.sourceforge.jeuclid.DOMBuilder

open
nobody
None
5
2010-09-16
2010-09-16
Dan
No

I was trying to use the JEuclid view, first creating a document wiht DOMBuilder.createJeuclidDom I run into several problems.

Let\'s take as example:

<mml:math xmlns:mml=\"http://www.w3.org/1998/Math/MathML\">
<mml:apply>
<mml:plus/>
<mml:ci> F </mml:ci>
<mml:ci> G </mml:ci>
</mml:apply>
</mml:math>

If you pass the parameter addNamespace=true to the createJeuclidDom you will get a cryptic error in the console:

Error at xsl:copy on line -1 of :
org.w3c.dom.DOMException: The namespace URI \"null\" is invalid. Current node type: 1, name: null.

This happens because the transformation from DOMBuilder that adds namespaces, creates a DocumentElement from jeuclid. This factory knows only presentation MathML elements, and the \"apply\" element is not recognized.

You should modify the code:

if (addNamespace) {
documentElement = this.applyTransform(documentElement,
this.namespaceTransformer);
}

from the DOMBuilder in something that does not construct a jeuclid DOM, but a standard DOM, that will be then processed by the \"contentTransformer\" to convert the apply element to other presentation elements.

Another problem is with the content to presentation stylesheet. If you have a valid MathML (but semantically incorrect), as the one:

<mml:math xmlns:mml=\"http://www.w3.org/1998/Math/MathML\">
<mml:apply>
</mml:apply>
</mml:math>

then the stylesheet /net/sourceforge/jeuclid/content/mathmlc2p.xsl will let the \"apply\" element pass into the output. The effect is the same message, indicating in fact that the JEuclidElementFactory tries to create a foreign element.

The cause is the existence of the copy template at the end of the stylesheet.

<xsl:template match=\"*\">

3727 <xsl:copy>

3728 <xsl:for-each select=\"@*\">

3729 <xsl:copy/>

3730 </xsl:for-each>

3731 <xsl:apply-templates/>

3732 </xsl:copy>

3733 </xsl:template>

The stylesheet should copy only elements that are known by the JEuclidElementFactory.

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks