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

RE: rogue xmlns="" in output xhtml

Subject: RE: rogue xmlns="" in output xhtml
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 15 Oct 2005 20:17:15 +0100
t2 rogue
> I'm
> guessing it has to do with the fact that I added the XTHML 
> namespace to the
> code thus:
> 
>    <html xmlns="http://www.w3.org/1999/xhtml" >
> 

Yes. If you do this:

 <xsl:template match="/">
   <html xmlns="http://www.w3.org/1999/xhtml" >
     <xsl:call-template name="t2"/>
   </html>
 </xsl:template>

 <xsl:template name="t2">
   <body/>
 </xsl:template>

then you are generating an element whose name is
{http://www.w3.org/1999/xhtml}html, with a child whose name is {}body.
(Using "{uri}local" to indicate an expanded name.) To represent a body
element that's in no namespace as a child of an html element in the
http://www.w3.org/1999/xhtml namespace, the system has to add a namespace
undeclaration xmlns="". Whereas if you generate both elements in the same
namespace, the child element won't need any extra namespace declarations.

Remember that you choose what namespace to put your elements in; the system
then reflects this choice by generating suitable namespace declarations. If
the element is generated as a literal result element, then its name in the
result tree (uri + local-part) is the same as the name of the literal result
element in the stylesheet.

The mistake is to imagine that a namespace declaration in the stylesheet
such as xmlns="http://www.w3.org/1999/xhtml" is copied to become a namespace
declaration in the result tree. That's not the way it works.

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

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-2011 All Rights Reserved.