You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Allen Brookes <ab...@roguewave.com> on 2003/05/23 23:25:31 UTC

default namespace declaration in transformed documents

I am having a problem with a default namespace declaration in a transformed
XML document.  Xalan seems to want to add a default namespace declaration
which incorrectly overrides my default namespace declaration. 

Can someone tell me under what circumstances Xalan adds a default namespace
declaration?

Thanks,
Allen

Re: default namespace declaration in transformed documents

Posted by da...@us.ibm.com.



Hi Allen,

This usually happens because you are copying nodes from the source document
which are in that namespace, or because you have literal result elements in
the stylesheet which are in that namespace.

If you can, please post a small sample input document and stylesheet that
reproduce the problem.  This is a common question, and usually, Xalan is
doing the right thing, but there may be a bug that has not been discovered
yet.

Dave



                                                                                                                                    
                      Allen Brookes                                                                                                 
                      <abrookes@roguew         To:      xalan-j-users@xml.apache.org                                                
                      ave.com>                 cc:      (bcc: David N Bertoni/Cambridge/IBM)                                        
                                               Subject: default namespace declaration in transformed documents                      
                      05/23/2003 05:25                                                                                              
                      PM                                                                                                            
                                                                                                                                    



I am having a problem with a default namespace declaration in a transformed
XML document.  Xalan seems to want to add a default namespace declaration
which incorrectly overrides my default namespace declaration.

Can someone tell me under what circumstances Xalan adds a default namespace
declaration?

Thanks,
Allen



Re: default namespace declaration in transformed documents

Posted by Jon Blake <jo...@addr12.addr.com>.
On Fri, 23 May 2003, Allen Brookes wrote:

> I am having a problem with a default namespace declaration in a transformed
> XML document.  Xalan seems to want to add a default namespace declaration
> which incorrectly overrides my default namespace declaration. 
> 
> Can someone tell me under what circumstances Xalan adds a default namespace
> declaration?

I might not be understanding your problem, but I believe that I ran into a
similar problem. I was creating XHTML documents and Xalan kept adding
empty default namespace to every element that was at the top level of a
template. After doing it the wrong way, I did the following:

<xsl:transform version="1.0"
  xmlns="http://www.w3.org/1999/xhtml"
  . . .>

This tells Xalan that every element in the transformation without an
explicity namespace is in your specific namespace (in this case the XHTML
namespace).

<xsl:template match="foo">
 <p><xsl:apply-templates /></p>
</xsl:template>

Before the fix, using the above template Xalan was producing things like:

<p xmlns="">. . .</p>

The default namespace declaration disappeared when I applied the default
namespace declaration to the xsl:transorm element.

HTH.

--
Jonathan Blake


Re: default namespace declaration in transformed documents

Posted by Joseph Kesselman <ke...@us.ibm.com>.



I'd bet dollars to donuts that the output is correct, but simply not what
you expected because you forgot which namespaces were active in the source
document and stylesheet.

>Can someone tell me under what circumstances Xalan adds a default
namespace
>declaration?

Xalan adds a default namespace declaration when you are outputting a
non-prefixed element which is not in the same default namespace as its
parent. The alternative would be to force a prefix onto that element and
make sure that prefix is defined, which comes out to much the same thing
unless that prefix is already in scope.

One or the other of these patches is required for correct namespace-aware
processing. You may want to glance at  the namespace normalization
algorithm described in the DOM Level 3 Working Draft, which has to solve
the same problem.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk