Re: [xsl] Extra xmlns=""

Subject: Re: [xsl] Extra xmlns=""
From: Larry Garfield <lgarfiel@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 17 Jul 2001 08:52:03 -0500
David Carlisle wrote:

> > I've noticed that some XSLT engines, when converting from XML to XHTML,
> > will insert extra empty xmlns="" attributes into some tags,
> Only if you generate elements in the null namespace when their parents
> are in a different namespace. You'll need to show a snipped of XSL
> that's doing this.
> David

Here's some of the relevant templates from the XSLT file (the whole file is a
bit large to past in here):

====== XSLT =====

<xsl:template match="article">
 <html xmlns=""; lang="en" xml:lang="en">
    <xsl:value-of select="title"/>
    <xsl:if test="titleabbrev != ''"><![CDATA[ (]]><xsl:value-of
   <link rel="stylesheet" type="text/css" href="sssf.css" title="sssf"/>
   <xsl:apply-templates select="title"/>
   <xsl:apply-templates select="subtitle"/>
   <xsl:apply-templates select="titleabbrev"/>
   <xsl:apply-templates select="articleinfo"/>
   <xsl:apply-templates select="sect1"/>
   <p class="ValidLogos">
    <a href="";>
     <img src=""; class="NoBorder"
alt="Valid XHTML 1.0!" height="31" width="88"/>
    <a href="";>
     <img src="";
class="NoBorder" alt="Valid CSS!"/>

<xsl:template match="articleinfo">
 <xsl:apply-templates select="keywordset"/>
 <xsl:apply-templates select="authorgroup"/>
 <xsl:apply-templates select="revhistory"/>

<xsl:template match="keywordset">
  <xsl:apply-templates select="keyword[@role='type'] |
  <xsl:apply-templates select="keyword[@role='category']"/>

<xsl:template match="revhistory">
 <xsl:apply-templates select="revision[position()=1]"/>

<xsl:template match="revision">
 <h2><![CDATA[Mark ]]><xsl:number format="I" value="revnumber"/>
 <xsl:apply-templates select="revdescription"/>
 <xsl:apply-templates select="date"/>

<xsl:template match="revdescription/para[position()=1]">
 <div class="Signature">

<xsl:template match="revdescription/para[position()!=1]"/>

<xsl:template match="revision/date">
 <div class="ApprovalDate">

<xsl:template match="sect1">

<xsl:template match="sect2">

<xsl:template match="sect1/title">

<xsl:template match="sect2/title">

<xsl:template match="para">


And here's a portion of one of the XML input files (Note:  Don't think too
hard about the content, it's for a rather wacky sci-fi club):

===== XML =====

<article class="techreport" id="bigrig">
 <title>Basic I/O Grunt, Rigid Information Grouper</title>
   <keyword role="type">Starship</keyword>
   <keyword role="category">Computer System</keyword>
    <date>9 September 1999</date>
     <para>Approved by Engineering Director Colin Wyers</para>
  <para>Faced with the growing [snip]</para>
  <para>Abraxis Shipworks, [snip]</para>
  <para>Nyetscape decided to design [snip]</para>
   <member>Handling all general ship operation input</member>
   <member>Control and translation of helm and ops functions</member>
   <member>transportation of raw and processed material and
   <member>Invoice and PO tracking data storage and categorization</member>
  <para>To this end, [snip]</para>
  <para>The database portion [snip]</para>
  <para>The Basic I/O Grunt, [snip]</para>


And here's the output I'm getting using MSXML.  I get the same thing in XT,
but not in Xalan-C or Xalan-J.

===== XHTML =====

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html lang="en" xml:lang="en" xmlns="";>
<title>Basic I/O Grunt, Rigid Information Grouper (BIGRIG)</title>
<link rel="stylesheet" type="text/css" href="sssf.css" title="sssf" />
<h1 xmlns="">Basic I/O Grunt, Rigid Information Grouper</h1>
<h2 xmlns=""> (BIGRIG)</h2>
<h2 xmlns="">Starship Computer System</h2>
<div class="Designer" xmlns="">Designed by</div>
<div class="Designer" xmlns="">Larry Garfield</div>
<h2 xmlns="">Mark I</h2>
<div class="Signature" xmlns="">Approved by Engineering Director Colin
<div class="ApprovalDate" xmlns="">9 September 1999</div>
<hr />
<h2 xmlns="">Description</h2>
<p xmlns="">Faced with the [snip]</p>
<p xmlns="">Nyetscape decided to [snip]</p>
<ul xmlns="">
<li>Handling all general ship operation input</li>
<li>Control and translation of helm and ops functions</li>
<li>transportation of raw and processed material and machinery</li>
<li>Invoice and PO tracking data storage and categorization</li>
<p xmlns="">To this end, [snip]</p>
<p xmlns="">The database portion [snip]</p>
<p xmlns="">The Basic I/O Grunt, [snip]</p>
<hr />
<p class="ValidLogos">
<a href="";>
<img src=""; class="NoBorder" alt="Valid
XHTML 1.0!" height="31" width="88" />
<a href="";>
<img src="";
class="NoBorder" alt="Valid CSS!" />


The problem, of course, is al of those extra xmlns="" hanging around.
Looking at it again, it appears to be happening in all of the block level
tags (p, hx div), except for the ones that have a class declaration for CSS.
So either XT and MSXML are in error, or there's a bug in my script and Xalan
is in error by correcting it.

Any suggestions?

Larry Garfield

Do you have a PalmOS Organizer?  Click here to add me to your address book:

-- "If at first you don't succeed, skydiving isn't for you." :-)

 XSL-List info and archive:

Current Thread