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

RE: [xsl] Node renaming problem


Subject: RE: [xsl] Node renaming problem
From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Oct 2002 10:46:28 -0600

My mailer munged the verbatim HTML tags. Here it is again:

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:
&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://www.w3.org/1998/Math/MathML">
&lt;head>
&lt;title>Variable on One Side</title>
&lt;!-- Design Science MathPlayer -->
&lt;object id="behave1" classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987"><!-- -->&lt;/object>
&lt;?import namespace="m" implementation="#behave1" ?>
&lt;/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
&lt;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



Current Thread
Keywords