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

Re: xmlns=""

Subject: Re: xmlns=""
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 22 Feb 2011 15:15:40 +0100
Re:  xmlns=""
Merrilees, David wrote:

When I add a default namespace to an element, it's direct descendants acquire an xmlns="". Does anyone know why this is, or how to avoid it?


<?xml version="1.0" encoding="UTF-8"?>
         <body id="home">


<xsl:template match="/html">
         <html xmlns="http://www.w3.org/1999/xhtml">
                 <xsl:sequence select="./node()"/>


<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
         <head xmlns="">

The input element you copy has no namespace thus in the new document to preserve that information the serializer adds the xmlns="".
If you want to put your input elements that are in no namespace into the XHTML namespace then you need to do that for each result element you create.

So instead of doing xsl:copy or copy-of or sequence to copy elements from the input to the output you need to use apply-templates with e.g.
<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="http://www.w3.org/1999/xhtml">


	Martin Honnen

Current Thread


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.
First Name
Last Name
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.