Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MrBilde 13 posts 33 karma points
    Oct 21, 2011 @ 13:54
    MrBilde
    0

    Double entries using Cultiv Search Engine Sitemap

    Just installed the package "CultivSearchEngineSitemap 2.0.1" on my Umbraco 4.7.1.
    But it seems to generate double entries like this:

    <urlset xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
    <url>
    <loc>http://domain.comhttp://domain.com/site.aspx</loc>;
    <lastmod>2011-10-18T14:55:54+00:00</lastmod>
    </url>

    I found out that if i commented out urlPrefix it would remove the first "http://domain.com" entry:
    (seems like NiceUrl returns the full path with prefix?)

    <loc>
    <!--xsl:value-of select="$urlPrefix" /-->
    <xsl:value-of select="umbraco.library:NiceUrl(@id)" />
    </loc>

    But the schemaLocation still have double entry. Any ideas why this is happening?

    Here is my sitemap.xslt:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour ">

      <xsl:output method="xml" omit-xml-declaration="yes"/>

      <xsl:param name="currentPage"/>

      <xsl:variable name="urlPrefix">
        <xsl:text>http://</xsl:text>
        <xsl:value-of select="umbraco.library:RequestServerVariables('HTTP_HOST')" />
      </xsl:variable>

      <!-- update this variable on how deep your site map should be -->
      <xsl:variable name="maxLevelForSitemap" select="100"/>

      <xsl:template match="/">
        <!-- change the mimetype for the current page to xml -->
        <xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/>

        <xsl:call-template name="drawNodes">
          <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::*[@level=1]"/>
        </xsl:call-template>
      </xsl:template>

      <xsl:template name="drawNodes">
        <xsl:param name="parent"/>
        <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0
                or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)
                and @level &lt;= $maxLevelForSitemap ">

          <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1'] | $parent/node [string(./data [@alias='umbracoNaviHide']) != '1']">
            <!-- If the document does not have a template, nothing is shown in the frontend anyway.
            So this is not proper content and should not be in the sitemap -->
            <xsl:if test="@template &gt; 0">
              <url>
                <loc>
                  <!--xsl:value-of select="$urlPrefix" /-->
                  <xsl:value-of select="umbraco.library:NiceUrl(@id)" />
                </loc>
                <lastmod>
                  <xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'yyyy-MM-ddTHH:mm:ss+00:00')" />
                </lastmod>
                <xsl:if test="./data [@alias='searchEngineSitemapChangeFreq'] != '' or searchEngineSitemapChangeFreq != ''">
                  <changefreq>
                    <xsl:value-of select="./data [@alias='searchEngineSitemapChangeFreq'] | searchEngineSitemapChangeFreq" />
                  </changefreq>
                </xsl:if>
                <xsl:if test="./data [@alias='searchEngineSitemapPriority'] != '' or searchEngineSitemapPriority != ''">
                  <priority>
                    <xsl:value-of select="./data [@alias='searchEngineSitemapPriority'] | searchEngineSitemapPriority" />
                  </priority>
                </xsl:if>
              </url>
            </xsl:if>

            <xsl:if test="(count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevelForSitemap]) &gt; 0) or (count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level &lt;= $maxLevelForSitemap]) &gt; 0)">
              <xsl:call-template name="drawNodes">
                <xsl:with-param name="parent" select="."/>
              </xsl:call-template>
            </xsl:if>

          </xsl:for-each>
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>
  • MrBilde 13 posts 33 karma points
    Oct 21, 2011 @ 14:02
    MrBilde
    0

    Ops, just noticed that the schemaLocationis indeed isn't a double entry :-)

    But it seems like the urlPrefix might be a bug?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Oct 21, 2011 @ 23:52
    Chriztian Steinmeier
    0

    Hi MrBilde,

    The reason for the urlPrefix in the macro (I think) is because NiceUrl() normally doesn't output the full URL - but there's a web.config setting for controlling that, so you might find that in your case it's set to output complete URLs?

    /Chriztian

    - Yep, the schemaLocation attribute actually needs to be like that :-) 

  • MrBilde 13 posts 33 karma points
    Oct 24, 2011 @ 09:04
    MrBilde
    0

    Hm.. can't recall that I've changed anything in the web.config like that, but it sounds very plausible. Thanks for the help!

Please Sign in or register to post replies

Write your reply to:

Draft