[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] namespace prefix weirdness


Subject: RE: [xsl] namespace prefix weirdness
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 17 Aug 2004 23:47:16 +0100

> >           <modsCollection xmlns="http://www.loc.gov/mods/v3">
> >              <key xmlns="">test</key>
> >              <_0:mods xmlns=""
> > xmlns:_0="http://www.loc.gov/mods/v3" 
> ID="Mitchell1996b">>
> >                 <titleInfo xmlns="http://www.loc.gov/mods/v3">
> >                    <title>Introduction</title>
> >                    <subTitle>Public Space and the City</subTitle>
> >                 </titleInfo>
> 

This is certainly rather unusual output, though it's perfectly correct
according to the spec.

I think that what's happening here is that when Saxon copies an element
(xsl:copy-of applied to the mods element in this case), it first copies all
the namespace nodes from the source element, then performs namespace fixup
to decide what prefix to allocate to the element name (and to any attribute
names). While copying the namespace nodes, it has decided to generate an
xmlns="" undeclaration, because the source element does not have the
namespace xmlns="http://www.loc.gov/mods/v3" in scope and it therefore needs
to be undeclared. When it comes to generate the prefix for the mods element,
it decides that the default prefix "" is already in use, so it has to
generate an arbitrary new prefix.

In fact if Saxon delayed the decision to generate the xmlns="" undeclaration
until after namespace fixup, it could reassign the default ("") prefix, and
generate a more pleasing output tree. But it doesn't.

Michael Kay


Current Thread