RE: [xsl] xslt 1.0 namespace on output doc

Subject: RE: [xsl] xslt 1.0 namespace on output doc
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 12 Apr 2006 17:35:05 +0100
> should get transformed by:
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet version="1.0"
> 			xmlns="";
> 			xmlns:xhtml="";

> <xsl:template match="/">
> 	<html lang="de" xml:lang="de">
> into the following xhtml (apart from white-space, and well, not really


> <html xmlns=""; lang="de" xml:lang="de">


> But only Transformiix (Fx 1.5.01) gives me the expected 
> result, whereas
> SAXON 6.5.5 and MSXML 3 both add
> xmlns:xhtml="";
> to the html element.

With XSLT 1.0, the majority are usually in the right. The specification says
that for a literal result element (such as <html>) all namespace nodes that
are in-scope for that element in the stylesheet are copied to the result
document. This includes the namespace node that maps the prefix "xhtml" to
the URI ""; 

You might be able to prevent this happening with exclude-result-prefixes.
This isn't guaranteed to work, however: some processors will ignore the
exclude-result-prefixes if the namespace in question is one that is actually
used in the result tree. This is conformant behavior because XSLT 1.0
basically says the serializer can add any namespaces it wants. By contrast,
the behavior you are seeing from Transformiix appears to be non-conformant.

Michael Kay

Current Thread