Re: Problem with namespace and server-side XSLT

Georges Discry <[email protected]>
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Message-ID <[email protected]>
Martin Honnen a écrit :
> Georges Discry wrote:
> 
>> It seems that I'll have to use a <xsl:attribute name="xmlns"> to cope 
>> with this problem...
> 
> Namespace declarations are not attributes in terms of the XSLT/XPath 
> data model so trying to create a namespace declaration with 
> xsl:attribute is not going to work.
> 
> I am not sure what exactly you are trying to do but a namespace 
> declaration needs to be done on an element itself or an ancestor so you 
> need e.g.
>   <xsl:stylesheet
>     xmlns="http://www.w3.org/1999/xhtml"
> or e.g.
>   <xsl:template match="/"
>     xmlns="http://www.w3.org/1999/xhtml">
> 
Actually, it's more luck than anything else if the <xsl:attribute 
name="xmlns"> works for me, but clearly it's not the solution.
I've already tried to declare the namespace in the xsl:stylesheet 
element. But as I've explained, I'm using several xsl documents linked 
altogether with xsl:import. The "first" xsl document is generated for 
content negociation, as, excpet for the namespace, everything related to 
the output language can be specified in the xsl:output element (e.g. 
doctype, method, xml-declaration...) which is really usefull, as if you 
use XHTML element while keeping in mind the backward compatibility 
(which is not hard at all), you can serve the language you want only by 
changing the xsl:output.
But when it comes to namespace, I have several problems with XHTML1.1 or 
HTML4.01. My aim is to be able to switch automatically between 
namespaces, and if a language (HTML in fact) doesn't require one, then 
no xmlns attribute at all in the output code.
So what are the problems :
-If I declare the namespace in the xsl:stylesheet element of the 
generated xsl document, it works great with XHTML1.0, but no namespace 
declaration in XHTML1.1 (apparently because the xsl doc is not 
generating any tags). I don't know which behavior is right or wrong, but 
this is weird. (If I use the VS XSLT processor for generating the page 
in XHTML1.0, it doesn't declare the namespace so I guess it's a bonus 
from the XSL extension)
-If I declare the namespace in the xsl document generating the html 
node, I won't be able to change the namespace at will and in HTML, there 
will be a xmlns attribute we don't want.

For now, it's not time for compromise (I could easily drop HTML4.01 or 
XHTML1.1 support, but no) and if it's possible to keep it as simple as 
possible (like just generating a xsl document)

And I think I will clean a bit my code and put the main files online so 
if this method interests someone...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.