[xsl] Specifying the XHTML XMLNS

Subject: [xsl] Specifying the XHTML XMLNS
From: knocte <knocte@xxxxxxxxx>
Date: Wed, 28 Sep 2005 14:59:39 +0200
Hello.

I am having the "xhtml xmlns" issue that has already been discussed in
this list. If I specify it using xsl:attribute I finally get the xmlns
attribute specified in many nodes instead of only in the <html> one.

I have read many messages from that thread but I don't get to finally
understand all the "namespace stuff"... I will give you my specific
style-sheet so as to see if anyone could point me about the specific
change I should do for finally getting
xmlns="http://www.w3.org/1999/xhtml"; only in the <html> tag:

XML:

<?xml version="1.0" encoding="utf-8"?>
<page>
  <title>My specific title</title>
  <head>
    <link rel="stylesheet" href="./css/login.css" type="text/css" />
    <script type="text/javascript" src="./js/login.js"></script>
  </head>
  <content>
    <h2>Test</h2>
  </content>
</page>


XSLT:

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:output method="xml" indent="no"
              doctype-public="-//W3C//DTD XHTML 1.1//EN"
              doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";
              encoding="ISO-8859-15" />

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/page">
    <html>
      <xsl:attribute name="xml:lang">es</xsl:attribute>

      <head>
        <title>Main app title - <xsl:value-of select="title" /></title>
        <meta name="author" content="knocte" />

        <script type="text/javascript" src="./js/general/amuse.js"></script>
        <script type="text/javascript"
src="./js/general/general.js"></script>
        <link rel="stylesheet" href="./css/general/site.css" type="text/css"
/>

        <xsl:apply-templates select="head/*" />

      </head>

      <body>

        <div id="divHeader">This is my header</div>

        <div id="divContent">
          <xsl:apply-templates select="content/*" />
        </div>

        <div id="divHeader">This is my footer</div>

      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>


Result:

<html xml:lang="es">
  <head>
    <title>Main app title - My specific title</title>
    <meta name="author" content="knocte" />
    <script type="text/javascript" src="./js/general/amuse.js"></script>
    <script type="text/javascript" src="./js/general/general.js"></script>
    <link rel="stylesheet" href="./css/general/site.css" type="text/css" />
    <link rel="stylesheet" href="./css/login.css" type="text/css"></link>
    <script type="text/javascript" src="./js/login.js"></script>
  </head>
  <body>
    <div id="divHeader">This is my header</div>
    <div id="divContent"><h2>Test</h2></div>
    <div id="divHeader">This is my footer</div>
  </body>
</html>


Thanks very much,

    Andrew  [  knocte  ]

--

Current Thread