Subject: Re: [xsl] yet another namespace question (unwanted xmlns="") From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Sun, 15 Aug 2010 18:23:47 +0100 |
On 15 August 2010 14:42, Birnbaum, David J <djbpitt@xxxxxxxx> wrote: > Dear XSL List, > >> Move the xmlns="http://www.w3.org/1999/xhtml" to the xsl:stylesheet element. Currently >> you have it inside of a template so that it only applies to the elements created in that template. > > Thanks very much to Martin and Michael for the quick response and the explanation. I now realize that I've been putting namespace declarations in the wrong place all my life (well, all the life of the namespace spec, anyway), thinking that because I want them to appear on the root element of my result document I should put them there in the stylesheet, instead of putting them on the root element of the stylesheet itself and letting them get copied to the root of the result. As a bonus, for the first time exclude-result-prefixes now seems to do what I've always wanted it to do. > I know what you mean... intuitively you stick the namespace on the root element of the result, and expect any elements added to the result (from wherever that may be) to take on that namespace, as you expect the processor to know what you are trying to do. Instead namespaces are defined in the xml-that-is-your-stylesheet... you have to treat your stylesheet as an xml file and check the scoping of the namespaces defined in that xml file. One way of demonstrating this is to generate some xhtml using 2 stylesheets, one that includes another: you have to declare the xhtml namespace in both files - if namespaces were controlled at the XSLT level you would only have to declare the xhtml namespace once in the primary stylesheet, but because its at the XML level, you have to declare it in both files. This is only really an issue when you have an unprefixed namespace, so if you follow the rule of "never change the default namespace" (or "always use a prefix") you are less likely to confuse people with it. -- Andrew Welch http://andrewjwelch.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] yet another namespace questio, Birnbaum, David J | Thread | Re: [xsl] yet another namespace que, Wendell Piez |
[xsl] yet another namespace questio, Birnbaum, David J | Date | [xsl] Q: XSLT 1.0 output of namespa, Hermann Stamm-Wilbra |
Month |