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

RE: Mysterious appearance of xmlns="" in output

Subject: RE: Mysterious appearance of xmlns="" in output
From: "Julian Reschke" <julian.reschke@xxxxxx>
Date: Fri, 8 Mar 2002 20:53:46 +0100
xmlns inserted
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Steve
> Rosenberry
> Sent: Friday, March 08, 2002 8:30 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Mysterious appearance of xmlns="" in output
>
>
>
> Well hopefully it's only mysterious to me...

Yep.

> I get extra xmlns="" attributes in different HTML tags in the output
> generated by MSXML4.  I've reduced the problem to the following XSLT:
> ---------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
>   <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
>
>   <!-- VERY SIMPLE ROOT TEMPLATE MAKES A SINGLE CALL TO Header-->
>   <xsl:template match="/">
>
>     <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
>
>       <xsl:call-template name="Header"/>
>
>     </html>
>
>   </xsl:template>
>
>   <!-- HEADER TEMPLATE SIMPLY OUTPUTS A BASIC HTML Head TAGSET-->
>   <xsl:template name="Header">
>
>     <head>
>       <meta http-equiv="Content-Type" content="text/html;

Make this:

	<meta xmlns="http://www.w3.org/1999/xhtml" http-equiv="Content-Type"
content="text/html;

>            charset=iso-8859-1"/>
>       <title>Title</title>
>     </head>
>
>   </xsl:template>
>
> </xsl:stylesheet>
> ---------------------------------------------------
>
>
> I expected the following output from the transformation:
> ---------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
>   <head>
>     <meta http-equiv="Content-Type"
>           content="text/html;
>           charset=iso-8859-1" />
>     <title>Title</title>
>   </head>
> </html>
> ---------------------------------------------------
>
> What I get instead is a 'head' tag that looks like this:
>
>     <head xmlns="">
>
> If I replace the <xsl:call-template name="Header"/> with the contents
> >from the Header template, the xmlns attribute is NOT inserted.
>
> If I remove the xmlns="http://www.w3.org/1999/xhtml" attribute from the
> <html> tagset and leave the <xsl:call-template name="Header"/>, the
> xmlns attribute again is NOT inserted.
>
> If I go back to inserting the <head> tagset with a call-template and
> change the Header template to the following (I know it's invalid HTML,
> but for testing purposes I don't believe that should matter):
> ---------------------------------------------------
>   <xsl:template name="Header">
>
>     <head/>
>       <meta http-equiv="Content-Type" content="text/html;
>            charset=iso-8859-1"/>
>       <title>Title</title>
>
>   </xsl:template>
> ---------------------------------------------------
>
> I get three extra xmlns="" attributes as follows:
> ---------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
>   <head xmlns="" />
>     <meta http-equiv="Content-Type"
>         content="text/html;
>         charset=UTF-8"
>         xmlns="" />
>     <title xmlns="">Title</title>
> </html>
> ---------------------------------------------------
>
> Does anyone understand this behaviour, and more importantly does anyone
> know how I can turn it off without sacrificing call-templates or the
> xmlns namespace definition?  Actually for that matter, I'm not sure what
> the xmlns namespace definition does for me.  I added it when I converted
> the website to XHTML just because I blindly copied from an example
> somewhere.  If I can sacrifice that without violating any spec, I will,
> although, I'd still like to understand what's happening...

It's just a matter of default namespace scoping. You could also add the
declaration to the stylesheet element (then you wouldn't have to repeat it).



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.