Copied to clipboard

Flag this post as spam?

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


  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Sep 06, 2011 @ 16:01
    Tim
    0

    Sitemap Macro Running Slow?

    Having a very odd problem where a fairly standard recursive sitemap XSLT macro (pretty much the one that comes out of the box, with an additional name() check to exclude certain docTypes from the map).

    On some sites, it works fine, renders a sitemap for 1000's of pages in less than a second. On a couple of sites though, small sitemaps (<50 pages) are taking 2 - 3 minutes to render.

    Wierdly, if I add an empty <xsl:text> block after the recursive call, the macro renders at normal speeds.

    Anyone come across this before and got any ideas what might be causing it?

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Sep 06, 2011 @ 20:44
    Lee Kelleher
    0

    Hi Tim,

    Hmmm... taking a complete stab in the dark - thinking that it could be related to the "umbraco.library" calls (IsProtected, IsLoggedOn)?

    Can't say why adding an empty <xsl:text> would speed up the rendering ... very strange!

    Cheers, Lee.

  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Sep 07, 2011 @ 01:30
    Chriztian Steinmeier
    0

    Hi Tim,

    You sure you didn't leave uBrokeIt on those :-) ?

    Try the "SSS" and see how it performs:

    <?xml version="1.0" encoding="utf-8" ?>
    <!--
        "SSS" - Super Simple Sitemap :-)
    -->
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umb="urn:umbraco.library"
        exclude-result-prefixes="umb"
    >
    
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
        <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
        <xsl:template match="/">
            <ul>
                <xsl:apply-templates select="$siteRoot" />
            </ul>
        </xsl:template>
    
        <xsl:template match="*[@isDoc][not(umbracoNaviHide = 1)]">
            <li>
                <a href="{umb:NiceUrl(@id)}">
                    <xsl:value-of select="@nodeName" />
                </a>
                <xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)]">
                    <ul>
                        <xsl:apply-templates select="*[@isDoc][not(umbracoNaviHide = 1)]" />
                    </ul>
                </xsl:if>
            </li>
        </xsl:template>
    </xsl:stylesheet>

    then add an empty template for the types you want to exclude, e.g.:

    <xsl:template match="SecretType1 | uBrokeItSettings | etc" />

    /Chriztian

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Sep 07, 2011 @ 09:51
    Tim
    0

    Thanks Guys!

    @Lee, I've taken off all of the library calls, and it makes no difference! I'm a bit stumped too, only thing I can think of is its to do with the output, possibly something to do with rendering out the output of the transform? It's definitely the @updateDate field that's the problem (see this post for others with the same issue: http://our.umbraco.org/forum/developers/xslt/21607-Slow-XSLT-for-Sitemap, Laurence G is the one who spots updateDate as the culprit, my own research confirms this, scroll to the lsat page for my detailed findings!)

    @Chriztian, I wish! Then I could just switch it off :P. The normal ul based sitemap works fine on the site, it seems to be adding the @updatedDate to the google sitemap that's the problematic field. I'll try your method though, and see if it makes a difference!

  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Sep 07, 2011 @ 10:40
    Chriztian Steinmeier
    0

    OK, reading through the other post I'm completely baffled. If it is indeed the case that adding a text node after the @updateDate field will speed up the generation of the result tree, I'd say it's a serious bug in the XSLT processor (MSXML).

    I could imagine there'd be a difference in using the "drawNodes" approach (calling templates recursively sending a lot of subtrees along for many levels) versus the apply-templates approach (of which I'm certain the processor is highly optimized for) - but that doesn't at all explain the @updateDate issue.

    Very curious to find out about this...

    Anyone (@Lee ?) tried to debug this in Visual Studio using a giant Umbraco.config file?

    /Chriztian 

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Sep 09, 2011 @ 13:01
    Tim
    0

    Hmmm, more sleuthing reveals that the problem gets worse the deeper in the tree that you traverse. Only listing level 2 nodes (everything under the homepage) is mad fast. Up it to level 3 nodes and it gets slightly slower, 4 is super slow and anything deeper than that and it takes almost a MINUTE to render.

    @Chriztian, I'm going to try your approach now and see if that works any better! Will keep this thread updated!

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Sep 09, 2011 @ 13:33
    Tim
    0

    @Chriztian, looks like the performance issue is still there. I'm also having trouble getting the exclude template be picked up. It always seems to match the more general template rather than the exclude one, regardless of what order I have the template blocks in inside the XSLT file....... Any ideas what's going on there?

  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Sep 09, 2011 @ 14:04
    Chriztian Steinmeier
    0

    Hi Tim,

    Yeah - I always forget that when posting to the forum :-) Should have learned by now, though...

    To force using the "exclude" template, add priority="1" to the template, like this:

    <xsl:template match="Type1 | Type2 | Typo3 | LOL" priority="1">

    /Chriztian

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Sep 09, 2011 @ 15:21
    Tim
    0

    Still doesn't work! I call the following in my initial match:

    <xsl:apply-templates select="$rootPage/descendant::*[@isDoc and not(umbracoNaviHide = 1)]" />

    The two templates I have are:

    <xsl:template match="*[@isDoc][not(umbracoNaviHide = 1)]" priority="2">
        <url>
          <loc>
            <xsl:value-of select="$url"/>
            <xsl:value-of select="umbraco.library:NiceUrl(@id)"/>
          </loc>
          <lastmod>
            <xsl:value-of select="./@updateDate" />
            <xsl:text>+00:00</xsl:text>
          </lastmod>
          <priority>
            <xsl:choose>
              <xsl:when test="./googlePriority &gt; 0">
                <xsl:value-of select="./googlePriority"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="0.5"/>
              </xsl:otherwise>
            </xsl:choose>
          </priority>
        </url>
        <xsl:text>
        </xsl:text>
      </xsl:template>
        
      <xsl:template match="DateFolder | ContentPage" priority="1">
        <url>IGNORED!!!</url>
      </xsl:template>
    </xsl:stylesheet>

    The second template is never matched, even though there are elements there which are DateFolder or ContentPage doctypes.......

    Any ideas?

Please Sign in or register to post replies

Write your reply to:

Draft