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

RE: root siblings contain xmlns=""

Subject: RE: root siblings contain xmlns=""
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 12 Jun 2006 09:05:42 +0100
xmlns root
Firstly, a couple of things that aren't directly relevant to your question:

(a) the element name "XML" is reserved. Most parsers will accept it (perhaps
with a warning) but it would be best to choose a different name.

(b) if something is the root node of a tree then by definition it has no
siblings. I assume you mean children.

The usual cause of your problem is a structure like this:

<xsl:template match="/">
 <root xmlns="a-namespace-uri">
   <xsl:call-template name="z"/>
 </root>
</xsl:template>

<xsl:template name="z">
  <child/>
</xsl:template>

The namespace of a constructed element is determined by the way you write
the stylesheet. In the above, you have asked for <root> to go in the
namespace "a-namespace-uri", and you have asked for <child> to go in the
"null" namespace. Elements are not placed in the same namespace as their
parent in the result tree, they are placed in the namespace determined by
the instruction that creates them. The serializer then produces namespace
declarations (and if necessary, invents namespace prefixes) to honour these
assignments. If you have an unwanted namespace declaration, it is because
you have created the element in the wrong namespace. If you changed the
second template to:

<xsl:template name="z">
  <child xmlns="a-namespace-uri"/>
</xsl:template>

(or if you moved the xmlns="a-namespace-uri" to the xsl:stylesheet element)
then the problem would go away.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: christoph.klocker@xxxxxx [mailto:christoph.klocker@xxxxxx] 
> Sent: 12 June 2006 07:16
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  root siblings contain xmlns=""
> 
> Hi,
> I do an transformation where I add a a schema declaration to the root
> element:
>  
> in the Stylesheet I define the root element as follows:
>  
>  
>  
>   <xsl:template match=3D"Element">
>  <XML xmlns=3D"http://www.something.at/Something" xmlns:xsi=3D"http:
>  //www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=3D"http:
>  //www.something.at/Something
>              http://www.something.at/something.xsd">
>           <xsl:apply-templates/>
>              <Arranger>
>                  <xsl:apply-templates 
> select=3D"$Var//ArrangerList/*"/>
>              </Arranger>
>      </XML>
> 
>   <xsl:template match=3D"node()|@*">
>          <xsl:copy>
>              <xsl:apply-templates/>
>          </xsl:copy>
>      </xsl:template>
>  
>  in the result document all the siblings of the root Element 
> contain  the empty namespace ' <element xmlns=3D""> ' 
>  How can I get rid of this=3F=3F
>  
>  I am using Saxon8B 
> 
>  thx Christoph
>  
> 
> 
> 
> This message and any attachment ("the Message") are 
> confidential. If you are not the intended recipient any use 
> is strictly prohibited. If you have received the Message in 
> error, please notify the sender immediately and delete the 
> Message from your system, any use is forbidden. 
> Correspondence via e-mail is primarily for information 
> purposes. KAG/RVG/RIFA/ImmoKAG neither makes nor accepts 
> legally binding statements unless otherwise agreed to the contrary

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.