Revision: 2385
http://qtitools.svn.sourceforge.net/qtitools/?rev=2385&view=rev
Author: davemckain
Date: 2010-03-18 16:57:53 +0000 (Thu, 18 Mar 2010)
Log Message:
-----------
Non-XML annotations are now stripped from the resulting MathML, removing the <semantics/> completely if it becomes redundant in the process (which is the case for most examples we have).
Modified Paths:
--------------
branches/mathassess/QTIEngine/web-app/WEB-INF/jqti-rendering-resources/org/qtitools/qti/rendering/mathassessengine/qti-common.xsl
Modified: branches/mathassess/QTIEngine/web-app/WEB-INF/jqti-rendering-resources/org/qtitools/qti/rendering/mathassessengine/qti-common.xsl
===================================================================
--- branches/mathassess/QTIEngine/web-app/WEB-INF/jqti-rendering-resources/org/qtitools/qti/rendering/mathassessengine/qti-common.xsl 2010-03-16 11:27:33 UTC (rev 2384)
+++ branches/mathassess/QTIEngine/web-app/WEB-INF/jqti-rendering-resources/org/qtitools/qti/rendering/mathassessengine/qti-common.xsl 2010-03-18 16:57:53 UTC (rev 2385)
@@ -372,7 +372,7 @@
</xsl:choose>
</xsl:template>
- <!-- mathml (any) -->
+ <!-- Keep MathML by default -->
<xsl:template match="m:*" as="element()">
<xsl:element name="{local-name()}" namespace="http://www.w3.org/1998/Math/MathML">
<xsl:copy-of select="@*"/>
@@ -380,6 +380,23 @@
</xsl:element>
</xsl:template>
+ <!-- MathML parallel markup containers: we'll remove any non-XML annotations, which may
+ result in the container also being removed as it's no longer required in that case. -->
+ <xsl:template match="m:semantics" as="element()*">
+ <xsl:choose>
+ <xsl:when test="not(*[position()!=1 and self::m:annotation-xml])">
+ <!-- All annotations are non-XML so remove this wrapper completely (and unwrap a container mrow if required) -->
+ <xsl:apply-templates select="if (*[1][self::m:mrow]) then *[1]/* else *[1]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- Keep non-XML annotations -->
+ <xsl:element name="semantics" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:apply-templates select="* except m:annotation"/>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
<xsl:template match="m:*/text()" as="text()">
<!-- NOTE: The XML input is produced using JQTI's toXmlString() method, which has
the unfortunate effect of indenting MathML, so we'll renormalise -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|