[xsl] removing a null namespace

Subject: [xsl] removing a null namespace
From: Gavin Montague <lists@xxxxxxxxxxxxxxx>
Date: Fri, 29 Apr 2005 13:03:59 +0100

I'd be grateful if someone could give me an answer/better solution to my problem....

I have a document which contains, in part, some fragments of xhtml. I'm using copy-of to pass these elements through to the final xhtml document unaltered but I find they are having a null namespace added. Here are some cut down's that will hopefully explain what I mean...

///////////////////////// xsl ///////////////////////////
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns="http://www.w3.org/1999/xhtml";>
<xsl:output method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes"
<xsl:template match="/">
<html lang="en" xml:lang="en">
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<xsl:apply-templates select="document/metadata" />
<link rel="stylesheet" type="text/css" href="/resources/sample.css" />
<div id="container">
<xsl:apply-templates select="document/content/markdown" />

<xsl:template match="markdown">
<xsl:copy-of select="child::*"/>
///////////////////////// output ///////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; lang="en" xml:lang="en">
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="/resources/sample.css"/>
<div id="container">

<h1 xmlns="">header</h1>
<p xmlns="">Lorem <em>ipsum</em> dolor sit amet, consectetuer adipiscing elit. Sed at justo id eros mollis lobortis. Donec dignissim. Aenean arcu. Nulla ultrices. Ut nec urna sed turpis elementum vehicula. Donec pretium mollis urna. Pellentesque pulvinar dui et erat. Donec sit amet dolor. Proin non dolor non nulla ullamcorper bibendum. Sed tempor ligula quis risus. Praesent a sapien nec leo imperdiet ultricies. Etiam ac justo. Maecenas euismod, dui ac aliquam tincidunt, erat sem hendrerit purus, eu dignissim sem sem sed odio. Suspendisse at leo. Phasellus vitae mauris et arcu malesuada aliquam. Mauris et pede. Vestibulum et augue.</p>
The xml document (not included here, but the relevant section is just plain <h1>header</h1><p>lipusm....</p>.

As I understand it doing a copy-of will include the namespace of the elements and, as there is no namespace in the original xml, this is "".

My problem is, how can I stop this being carried over into the transformed document? I can't use exclude-result-prefixes to exclude "", unless I'm mistaken.

Any help would be gratefully received.


Current Thread