RE: [xsl] Getting rid of namespace attribute under SQL2000 XML output

Subject: RE: [xsl] Getting rid of namespace attribute under SQL2000 XML output
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 18 Apr 2002 09:46:07 +0100
> From a previous thread, I
> understand that the output of these namespace declarations
> are by design.
> Any good reasons for this?
>
There are two reasons that <xsl:copy> copies all the in-scope namespaces
along with the element node being copied.

Firstly, there is no way of knowing which namespaces are actually needed,
because it is allowable for XML documents to use namespace prefixes in the
content of elements or attributes. There's been a lot of recent debate (e.g.
on xml-dev) saying this should never have been allowed, and perhaps it would
have been better if it weren't allowed, but it is allowed and we can't
change that now (and XSLT, of course does it itself).

Secondly, if you're copying a nested structure such as

<a xmlns:x="x.uri">
  <x:b/>
  <x:c/>
<a>

then it is probably best to keep the namespace declaration at the outer
(<a>) level even though it is only needed at the inner (<b>) level. That
way, you only get one namespace declaration in the output rather than
potentially thousands of identical namespace declarations.

Having said that, we currently have a mechanism (exclude-result-prefixes)
that prevents namespace nodes being copied from the stylesheet to the result
document, and I think there is a good case for a similar mechanism that
prevents them being copied from the source document, if that's what the user
wants.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread