[xml] empty xmlns attributes



At the moment I'm learning.  As I learn by doing I've just jumped
straight in.  I've gotten stuck many times and managed to figure it out
for my self.  But I've gotten stuck, and I really just don't understand.

Could someone possible point me in the right direction?

And if I'm showing immense amounts of clueness please tell me.

All I'm trying to do is take some xhtml-ish xml document, and apply a
XSLT stylesheet to turn it into xhtml 1.1.  It's working but the
W3C validation keeps moaning about `xmlns=""' attributes.  I just
can't work out why these attribute appear in the final output, or how to
get rid of them.

I'm using
    libxml2-2.5.2
    libxslt-1.0.25

I've included the files and the output below my sig.  If someone could
cast an expert eye over them....

Thanx.

-- 
TTFN, FNORD

Peter McGarvey
Freelance FreeBSD Hacker
(will work for bandwidth)

# ----  baz.xml -----------------

<?xml version="1.0"?>
<?xml-stylesheet
  xmlns="http://www.w3.org/1999/xhtml";
  type="text/xsl"
  href="baz.xsl" ?>

<document title="Lipsum (baz)">

<!-- foo -->

<h2 class="first">Quisque lacinia</h2>

<p> Quisque lacinia est id neque. Curabitur sit amet ante et turpis nonummy
volutpat. Integer placerat hendrerit magna. Integer cursus, nibh sed eleifend
Pellentesque porttitor tortor.  </p>

<h2>Fusce elit nisl</h2>

<p>Fusce elit nisl, porttitor ut, laoreet eget, fringilla quis, turpis.
aliquet quis, venenatis vitae, vulputate id, diam. Aliquam in justo at augue
cursus mattis. Vivamus eros. Ut cursus interdum ipsum.</p>

<p><i>Generated by <a href="http://www.lipsum.com/";>http://www.lipsum.com/</a>, the online Lipsum 
generator.</i></p>

<p>(yes, it is Latin)</p>

</document>


# ---- baz.xsl -------------------

<?xml version="1.0"?>
<!--
 vim: expandtab ts=2 autoindent
-->

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns="http://www.w3.org/1999/xhtml";
  >

  <xsl:strip-space elements="*"/>


  <xsl:output
    method = "xml"
    version = "1.0"
    encoding = "utf-8"
    omit-xml-declaration = "no"
    doctype-public = "-//W3C//DTD XHTML 1.1//EN"
    doctype-system = "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";
    cdata-section-elements = ""
    indent = "yes"
    media-type = "text/html" />

  <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en">
      <head>
        <title>
          <xsl:text>RED :: </xsl:text>
          <xsl:value-of select="/document/@title"/>
        </title>
      </head>
      <body>
        <h1>
          <xsl:value-of select="/document/@title"/>
        </h1>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="/document">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="a">
    <a href="{ href}">
      <img src="img/item.gif" alt="[click]"/>
      <xsl:value-of select="."/>
    </a>
  </xsl:template>

  <xsl:template match="*">
    <xsl:copy>

      <!-- xsl:copy-of select="@*" -->

      <xsl:for-each select="@*">
          <xsl:copy/>
      </xsl:for-each>

      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="comment()">
    <xsl:comment>
    <xsl:value-of select="."/>
    </xsl:comment>
  </xsl:template>

</xsl:stylesheet>



# ---- OUTPUT ---------------------------

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en">
  <head>
    <title>RED :: Lipsum (baz)</title>
  </head>
  <body>
    <h1>Lipsum (occam)</h1>
<!-- foo -->
    <h2 xmlns="" class="first">Quisque lacinia</h2>
    <p xmlns=""> Quisque lacinia est id neque. Curabitur sit amet ante et turpis nonummy
volutpat. Integer placerat hendrerit magna. Integer cursus, nibh sed eleifend
Pellentesque porttitor tortor.  </p>
    <h2 xmlns="">Fusce elit nisl</h2>
    <p xmlns="">Fusce elit nisl, porttitor ut, laoreet eget, fringilla quis, turpis.
aliquet quis, venenatis vitae, vulputate id, diam. Aliquam in justo at augue
cursus mattis. Vivamus eros. Ut cursus interdum ipsum.</p>
    <p xmlns="">
      <i>Generated by <a xmlns="http://www.w3.org/1999/xhtml"; href="http://www.lipsum.com/";>
        <img src="img/item.gif" alt="[click]"/>http://www.lipsum.com/</a>, the online Lipsum generator.</i>
    </p>
    <p xmlns="">(yes, it is Latin)</p>
  </body>
</html>






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]