This has turned into a product-specific question, not an XSLT question.
I've no idea how Internet Explorer matches the namespaces used in an XML
fragment generated using XSLT with namespaces declared in the HTML
document that your including it into. You'll have to ask a Microsoftie.
However, your post has highlighted that the XSLT 1.0 spec doesn't say
what should happen when you write <xsl:element name="m:something"/> and
the namespace prefix m isn't declared. So thanks, it's been useful!
Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Greg Faron
Sent: 10 October 2002 17:09
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Node renaming problem
At 02:10 AM 10/10/2002, you wrote:
I want to add a prefix to a particular node tree such that <math>
<apply>
<power/>
<ci>x</ci>
<cn>2</cn>
</apply>
</math>
becomes
<m:math>
<m:apply>
<m:power/>
<m:ci>x</m:ci>
<m:cn>2</m:cn>
</m:apply>
</m:math>
Presumably you want the result to be well-formed XML, in
which case the
"m" namespace must be declared? If not (and perhaps anyway),
your best
bet is to do a global replace using a text editor.
This is dynamic input from an html page component. I'm
basically using
a Java-based MathML editor to let the user construct a formula. That
MathML-formatted formula is then fed through an html form input and
displayed in the subsequent page via Internet Explorer's
Behavior assigning
ability. The top of new page looks like this:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:m="http://www.w3.org/1998/Math/MathML">
<head>
<title>Variable on One Side</title>
<!-- Design Science MathPlayer -->
<object id="behave1"
classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987"><!-- --></object>
<?import namespace="m" implementation="#behave1" ?>
</head>
...
The behavior looks for all tags that are prefixed with the
"m" namespace,
because that is what I instruct it to do in order to
distinguish it from
html markup.
Giving the elements a prefix of "m" is cosmetic.
I thought it was required for the plugin to identify which
elements that
it is responsible for.
The key question is
what namespace you want the elements in. You haven't bound
"m" to any
namespace. The spec says "the QName is expanded into an
expanded-name
(ie., a namespace-uri/local-name pair) using the namespace
declarations
in effect for the xsl:element element". It doesn't actually say what
happens if the prefix isn't in scope. Interestingly, this
omission is
still present in the XSLT 2.0 draft. My interpretation has
always been
that it is an error, but your XSLT processor seems to interpret it
differently, or to attempt a recovery action.
This is the result using MSXSL4.0:
<m:math xmlns="">
<m:apply xmlns="">
<m:power xmlns="" />
<ci>x</ci>
<cn>2</cn>
</m:apply>
</m:math>
This isn't well-formed XML, so I don't think any XSLT
processor should
produce this result. Raise a bug report.
For the sake of succinctness in the original post, I left out the
wrapping tag that I generated in root-matching template that
looked like <result xmlns="http://www.w3.org/1999/xhtml"
xmlns:m="http://www.w3.org/1998/Math/MathML">...</result>
Doesn't this satisfy the namespace definition?
3) Am I overcomplicating everything?
The key question is, are you trying to produce namespace-well-formed
XML output, and if so, what namespace do you want it in?
I want most of the output in the default namespace (for
traditional html
rendering) and small portions of it in the "m" namespace
which is mapped to
"http://www.w3.org/1998/Math/MathML".
Greg Faron
Integre Technical Publishing Co.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list