[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: 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> 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> 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".
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|