[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Unwanted (default) namespaces.

Subject: Re: Unwanted (default) namespaces.
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 8 Jul 2002 21:34:41 +0100
Re:  Unwanted (default) namespaces.
Hi Ed,

> I have an XML file which I process with an XSL stylesheet to create
> another XSL stylesheet included by other XSL stylesheets. This was
> working until I decided to change our XML files to be within a
> namespace to avoid possible future maintenance/integration issues.
> When I made this change, a namespace started showing up on an HTML
> tag which was being copied from the XML file to the generated XSL
> file: <html:br\> became <html:br xmlns="http://fedex.com/gnsl"/>.
>
> Outside of eliminating my use of the default namespace in my source
> XML file, I have discovered no way to circumvent the inclusion of
> this unwanted "xmlns" attribute. I am using the XalanC++ 'Xalan' and
> 'testXSLT' XSL processors.
>
>    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>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.