You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by David J Craigon <da...@arabidopsis.info> on 2003/04/10 17:03:24 UTC

Namespace question

I've got a stylesheet, right:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">

<xsl:template match="/">
<foo xmlns="http://superfoo.com">
<q />
<xsl:call-template name="fool" />
<q />
</foo>
</xsl:template>

<xsl:template name="fool">
<q />
</xsl:template>

</xsl:stylesheet>


Run on any piece of XML, and it gives:

<?xml version="1.0" encoding="UTF-8"?>
<foo xmlns="http://superfoo.com"><q/><q xmlns=""/><q/></foo>

What's up with the xmlns="" ? Why does the second q element (created 
from inside the called-template) fall out of the default namespace?

(Comparison- this doesn't happen with xsltproc).

Any help? Have I found a bug?

I'm using Xalan 1.5.0 rc1 with Xerces-C 2.2.0.

David


Re: Namespace question

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



Hi David,

You've found a bug in xsltproc.  Xalan-C is correct here.

The default namespace declaration on the element foo is not in scope on the
element q that is a child of the second template, since namespaces have
lexical scope within an XML document.  So, when you call the named
template, which generates an element q in the result tree, that element is
not in any namespace.  When Xalan serializes the result tree, it has to
generate the special xmlns declaration to turn off the default namespace,
since that element is not in any namespace.

You can experiment with this by moving the default namespace declaration
into the stylesheet element, which would mean that element q would be in
the default namespace.

Hope that helps...

Dave



                                                                                                                        
                      David J Craigon                                                                                   
                      <david@arabidops         To:      xalan-c-users@xml.apache.org                                    
                      is.info>                 cc:      (bcc: David N Bertoni/Cambridge/IBM)                            
                                               Subject: Namespace question                                              
                      04/10/2003 08:03                                                                                  
                      AM                                                                                                
                                                                                                                        



I've got a stylesheet, right:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:template match="/">
<foo xmlns="http://superfoo.com">
<q />
<xsl:call-template name="fool" />
<q />
</foo>
</xsl:template>

<xsl:template name="fool">
<q />
</xsl:template>

</xsl:stylesheet>


Run on any piece of XML, and it gives:

<?xml version="1.0" encoding="UTF-8"?>
<foo xmlns="http://superfoo.com"><q/><q xmlns=""/><q/></foo>

What's up with the xmlns="" ? Why does the second q element (created
from inside the called-template) fall out of the default namespace?

(Comparison- this doesn't happen with xsltproc).

Any help? Have I found a bug?

I'm using Xalan 1.5.0 rc1 with Xerces-C 2.2.0.

David