I have a sitemap in xml format which give me an error "no doctype found". Maybe there is something wrong with the source code, I hope that someone helps me with syntax corrected. I'm new at xml/xsl syntax so even if the sitemap works I have no idea to make validated my sitemap since I get always no doctype found... I used the copy instruction in order to put the html output to the browser with the doctype...
If I try to use output xml I see only plain text instead of html and the doctype is missing... help me with syntax... correct my file please... help me please!
sitemap.xml:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="sitemap.xsl" type="text/xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.alecos.it/games.php</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.alecos.it/diary_31032007.php</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
cut... cut...
</urlset>
sitemap.xsl:
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/>
<xsl:template match="/">
<html>
<head>
<title>SiteMap - Alecos Web Site By Alessandro Marinuzzi</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<div id="content">
<h1><a href="index.php" title="Alecos Web Site"><img src="gfx/Logo.png" alt="[Alecos WebSite SiteMap]" border="0"/></a></h1>
<div class="intro">
<p>Generated By <a href="http://www.alecos.it/">www.alecos.it</a>. Windows, Linux, Unix, MacOS(X) and Amiga programs, scripts, translations, articles and more...</p>
<p>This sitemap contains <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> URLs.</p>
</div>
<table class="sitemap" cellpadding="3">
<thead>
<tr>
<th width="80%">URL</th>
<th width="10%">Priority</th>
<th width="10%">Change Frequency</th>
</tr>
</thead>
<tbody>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:for-each select="sitemap:urlset/sitemap:url">
<tr>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
</td>
<td>
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</body>
</html>
</xsl:template>
<xsl:copy>
<xsl:apply-templates select="/"/>
</xsl:copy>
</xsl:stylesheet>
This works fine with doctype declaration and give me no errors found! I post here for other users that have the same problem. This is the final version of my sitemap.xsl. Share and use as you like!
This is that my code will produce, seems very good! Isn't true? Now I need a confirm that I'm correct now! Thanks!