<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:s="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
    exclude-result-prefixes="s image">
  <xsl:output method="html" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
    <html lang="tr">
      <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <meta name="robots" content="noindex, follow"/>
        <title>XML Site Haritası | MerkezHost</title>
        <style>
          body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:#f8fafc;color:#0f172a}
          header{background:#0b1224;color:#fff;padding:32px 16px}
          header div,main{max-width:1080px;margin:0 auto}
          h1{margin:0 0 6px;font-size:24px}
          header p{margin:0;color:#94a3b8;font-size:14px}
          main{padding:24px 16px}
          table{width:100%;border-collapse:collapse;background:#fff;border:1px solid #e2e8f0;border-radius:12px;overflow:hidden;font-size:14px}
          th{background:#f1f5f9;text-align:left;padding:12px 14px;font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:#475569}
          td{padding:11px 14px;border-top:1px solid #f1f5f9;word-break:break-all}
          a{color:#2549eb;text-decoration:none}a:hover{text-decoration:underline}
          .n{color:#64748b;white-space:nowrap}
        </style>
      </head>
      <body>
        <header><div>
          <h1>MerkezHost XML Site Haritası</h1>
          <p>Bu site haritası arama motorları içindir.
            <xsl:if test="count(s:sitemapindex/s:sitemap) &gt; 0"><xsl:value-of select="count(s:sitemapindex/s:sitemap)"/> alt site haritası listeleniyor.</xsl:if>
            <xsl:if test="count(s:urlset/s:url) &gt; 0"><xsl:value-of select="count(s:urlset/s:url)"/> adres listeleniyor.</xsl:if>
          </p>
        </div></header>
        <main>
          <table>
            <xsl:choose>
              <xsl:when test="count(s:sitemapindex/s:sitemap) &gt; 0">
                <tr><th>Site haritası</th><th>Son değişiklik</th></tr>
                <xsl:for-each select="s:sitemapindex/s:sitemap">
                  <tr>
                    <td><a href="{s:loc}"><xsl:value-of select="s:loc"/></a></td>
                    <td class="n"><xsl:value-of select="s:lastmod"/></td>
                  </tr>
                </xsl:for-each>
              </xsl:when>
              <xsl:otherwise>
                <tr><th>Adres</th><th>Görsel</th><th>Öncelik</th><th>Sıklık</th><th>Son değişiklik</th></tr>
                <xsl:for-each select="s:urlset/s:url">
                  <tr>
                    <td><a href="{s:loc}"><xsl:value-of select="s:loc"/></a></td>
                    <td class="n"><xsl:value-of select="count(image:image)"/></td>
                    <td class="n"><xsl:value-of select="s:priority"/></td>
                    <td class="n"><xsl:value-of select="s:changefreq"/></td>
                    <td class="n"><xsl:value-of select="s:lastmod"/></td>
                  </tr>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
          </table>
        </main>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
