I have a problem with namespaces and I produced a very simple example to demonstrate it. I think it is specific to xalan as I don't get the same behaviour from other processors. Any help would be appreciated. Perhaps I am doing something completely wrong or it is the version of Xalan I am using (2.6)
So... lets say that we have the following file:
<?xml version="1.0" encoding="UTF-8"?>
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p0" xmlns:m="http://www.w3.org/1998/Math/MathML">
<m:math>
<m:mrow>
<m:mn>2</m:mn>
<m:mo>+</m:mo>
<m:mi>p</m:mi>
</m:mrow>
</m:math>
</assessmentItem>
and we want to produce the following xml (that looks like html -its actually jsp but ignore that) and we want m:math to be copied to the math namespace="...." together with all subsequent element but all the m:mi elements would be copied in another namespace
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:mathqti="http://www.maths.ed.ac.uk/mathqti">
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mn>2</mn>
<mo>+</mo>
<mathqti:mi identifier="p"/>
</mrow>
</math>
</body>
</html>
But using the following XSLT I get
<mathqti:mi xmlns="http://www.w3.org/1999/xhtml" identifier="p"/>
I found ways to bypass the problem by not having a default namespace but this creates other problems in my stylesheet later on so I 'd like to have the default namespace unless this is wrong and it seems to me that it isn't (as I said other processors manage fine)
Any ideas ?
Thanks,
Manolis
XSLT:
<xsl:stylesheet
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:mathqti="http://www.maths.ed.ac.uk/mathqti"
xmlns:qti = "http://www.imsglobal.org/xsd/imsqti_v2p0"
exclude-result-prefixes="qti m" version="1.0">
<xsl:template match="qti:assessmentItem">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template><!-- we want all m: elements to be copied-->
<xsl:template match="m:*">
<xsl:element name="{local-name(.)}" namespace="http://www.w3.org/1998/Math/MathML">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<!-- lets assume that we want all m:mi elements to
be converted to some other namespace -->
<xsl:template match="m:mi">
<xsl:element name="mathqti:mi">
<xsl:attribute name="identifier"><xsl:value-of select="string(.)"/></xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
