This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Extra xmlns=""
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="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>
<xsl:value-of select="title"/>
<xsl:if
test="//article[@class]='specification'"><![CDATA[-class]]></xsl:if>
<xsl:if test="titleabbrev != ''"><![CDATA[ (]]><xsl:value-of
select="titleabbrev"/><![CDATA[)]]></xsl:if>
</title>
<link rel="stylesheet" type="text/css" href="sssf.css" title="sssf"/>
</head>
<body>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="subtitle"/>
<xsl:apply-templates select="titleabbrev"/>
<xsl:apply-templates select="articleinfo"/>
<hr/>
<xsl:apply-templates select="sect1"/>
<hr/>
<p class="ValidLogos">
<a href="http://validator.w3.org/check/referer">
<img src="http://www.w3.org/Icons/valid-xhtml10" class="NoBorder"
alt="Valid XHTML 1.0!" height="31" width="88"/>
</a>
<a href="http://jigsaw.w3.org/css-validator">
<img src="http://jigsaw.w3.org/css-validator/images/vcss.gif"
class="NoBorder" alt="Valid CSS!"/>
</a>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="articleinfo">
<xsl:apply-templates select="keywordset"/>
<xsl:apply-templates select="authorgroup"/>
<xsl:apply-templates select="revhistory"/>
</xsl:template>
<xsl:template match="keywordset">
<h2>
<xsl:apply-templates select="keyword[@role='type'] |
keyword[@role='variant']"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="keyword[@role='category']"/>
</h2>
</xsl:template>
<xsl:template match="revhistory">
<xsl:apply-templates select="revision[position()=1]"/>
</xsl:template>
<xsl:template match="revision">
<h2><![CDATA[Mark ]]><xsl:number format="I" value="revnumber"/>
</h2>
<xsl:apply-templates select="revdescription"/>
<xsl:apply-templates select="date"/>
</xsl:template>
<xsl:template match="revdescription/para[position()=1]">
<div class="Signature">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="revdescription/para[position()!=1]"/>
<xsl:template match="revision/date">
<div class="ApprovalDate">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="sect1">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="sect2">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="sect1/title">
<h2>
<xsl:apply-templates/>
</h2>
</xsl:template>
<xsl:template match="sect2/title">
<h3>
<xsl:apply-templates/>
</h3>
</xsl:template>
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
===============
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>
<titleabbrev>BIGRIG</titleabbrev>
<articleinfo>
<authorgroup>
<author>
<firstname>Larry</firstname>
<surname>Garfield</surname>
</author>
</authorgroup>
<keywordset>
<keyword role="type">Starship</keyword>
<keyword role="category">Computer System</keyword>
</keywordset>
<revhistory>
<revision>
<revnumber>1</revnumber>
<date>9 September 1999</date>
<revdescription>
<para>Approved by Engineering Director Colin Wyers</para>
</revdescription>
</revision>
</revhistory>
</articleinfo>
<sect1>
<title>Description</title>
<para>Faced with the growing [snip]</para>
<para>Abraxis Shipworks, [snip]</para>
<para>Nyetscape decided to design [snip]</para>
<simplelist>
<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
machinery</member>
<member>Invoice and PO tracking data storage and categorization</member>
</simplelist>
<para>To this end, [snip]</para>
<para>The database portion [snip]</para>
<para>The Basic I/O Grunt, [snip]</para>
</sect1>
</article>
===============
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Basic I/O Grunt, Rigid Information Grouper (BIGRIG)</title>
<link rel="stylesheet" type="text/css" href="sssf.css" title="sssf" />
</head>
<body>
<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
Wyers</div>
<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>
</ul>
<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="http://validator.w3.org/check/referer">
<img src="http://www.w3.org/Icons/valid-xhtml10" class="NoBorder" alt="Valid
XHTML 1.0!" height="31" width="88" />
</a>
<a href="http://jigsaw.w3.org/css-validator">
<img src="http://jigsaw.w3.org/css-validator/images/vcss.gif"
class="NoBorder" alt="Valid CSS!" />
</a>
</p>
</body>
</html>
=================
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
lgarfiel@students.depaul.edu
Do you have a PalmOS Organizer? Click here to add me to your address book:
http://signature.coola.com/?lgarfiel@students.depaul.edu
-- "If at first you don't succeed, skydiving isn't for you." :-)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list