Re: [xsl] Unwanted (default) namespaces.

Subject: Re: [xsl] Unwanted (default) namespaces.
From: "Edward L. Knoll" <ed.knoll@xxxxxxxxxxxxxx>
Date: Mon, 08 Jul 2002 16:41:22 -0600
> > I have an XML file which I process with an XSL stylesheet to create

[snip]

>
> >    The source XML file has the following (truncated) content:
> >    <TagLabels  xmlns:html="http://www.w3.org/1999/xhtml";
> >                xmlns="http://fedex.com/gnsl"; >
> >    <Tag name="GNSL_LOCATION_TYPE_CD">LOC<html:br/>TYPE</Tag>
> >    </TagLabels>
> >
> > The XSL stylesheet declaration and the templates which output the
> > offending statement follow:
> >
> >    <xsl:stylesheet version="1.0"
> >    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> >                     xmlns:html="http://www.w3.org/1999/xhtml";
> >                     xmlns:gnsl="http://fedex.com/gnsl";
> >                     exclude-result-prefixes="gnsl html" >
> [snip]
>
> OK, the namespace node that's creating the namespace declaration that
> you're seeing is the one in the source document. Your html:br element
> in the source document has a namespace node associated the default
> namespace with the namespace 'http://fedex.com/gnsl'. My guess is that
> you're copying the html:br element in your document, with something
> like:
>
> <xsl:template match="html:*">
>   <xsl:copy>
>     <xsl:apply-templates select="@*|node()" />
>   </xsl:copy>
> </xsl:template>
>
> When you copy an element, with xsl:copy or xsl:copy-of, you copy all
> its namespace nodes as well. So rather than doing that, you need to
> create an element without any associated namespace nodes, which means
> that you have to use xsl:element. Try using:
>
> <xsl:template match="html:*">
>   <xsl:element name="html:{local-name()}">
>     <xsl:apply-templates select="@*|node()" />
>   </xsl:element>
> </xsl:template>

You're right; that's how I was propogating the <html:br/> tag forward.  I
have to confess that namespaces are the one area of XSL (I'm currently
aware of) that I really don't have a handle on, so if you don't mind, I'd
like to "kick the dead horse" a bit.

In the source XML document, the <html:br/> tag is completely qualified.
Why is the choice being made to associate an additional (the default)
namespace with this node?  This seems like it will cause problems in
environments in which components from multiple namespaces are being
integrated.   Does this mean we shouldn't define default namespaces in
situations involving multiple namespaces?  I don't understand why that
node is being associated with a namespace other than what it was
explicitly referenced by.   Could you describe what aspect/rule
associated with the XSL transformation causes this additional namespace
to be associated with that node?

Thanks,
Ed



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


Current Thread