I want to list all level1 nodes and all level2 nodes and have this working but it is horrible slow (2 seconds). Anyone know how to make this more efficient?
<xsl:template match="/"> <!-- change the mimetype for the current page to xml --> <!--<xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/>-->
I'm experiencing similar problem using the code below;
However, I've tracked it down that when @updateDate (lastmod) is removed, performance is as would be expected. It seems that loading in either @updateDate or @createDate is causing huge performance issues.
This ghastly situation makes no sense at all. My head hurts and I am confused.
Lau
* also why format the date, when its in the correct format anyway?
<?xml version="1.0" encoding="utf-8" ?>
<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" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<!-- Navigation Sitemap XML (for search engines), Laurie 18th July, 2011 -->
<xsl:variable name="maxLevel" select="4"/>
<xsl:variable name="urlPrefix">
<xsl:text>http://</xsl:text>;
<xsl:value-of select="umb:RequestServerVariables('HTTP_HOST')" />
</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::*[@level=1 and @isDoc]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent"/>
<xsl:if test="umb:IsProtected($parent/@id, $parent/@path) = 0 or (umb:IsProtected($parent/@id, $parent/@path) = 1 and umb:IsLoggedOn() = 1) and @level <= $maxLevel ">
<xsl:for-each select="$parent/* [@isDoc and metaSitemap !='Hide Page,Hide Children' and metaSitemap !='Hide Page' and @level <= $maxLevel]">
<!-- If the document does not have a template, nothing is shown in the frontend anyway. -->
<xsl:if test="@template > 0">
<url>
<loc>
<xsl:value-of select="$urlPrefix" />
<xsl:value-of select="umb:NiceUrl(@id)" />
</loc>
<lastmod>
<xsl:value-of select="@updateDate" />
</lastmod>
<xsl:if test="metaSitemapChangeFreq">
<changefreq><xsl:value-of select="metaSitemapChangeFreq" /></changefreq>
</xsl:if>
<xsl:if test="metaSitemapPriority">
<priority><xsl:value-of select="metaSitemapPriority" /></priority>
</xsl:if>
</url>
</xsl:if>
<xsl:if test="count(./* [@isDoc and parent::*/metaSitemap !='Hide Children' and parent::*/metaSitemap !='Hide Page,Hide Children' and @level <= $maxLevel]) > 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>
<!-- Inspired by Cultiv's Brilliant Sitemap Package -->
<!-- Reference - http://our.umbraco.org/projects/website-utilities/cultiv-search-engine-sitemap -->
That way, the +00 won't drop down to the next line when you format the xslt in visual studio.
The date won't always be formatted correctly when different locale's are used, so that's why I put in the formatting. Are you sure it's not the formatdatetime that has the perf issue?
Just want to chime in that I was having the exact same performance problem in my self-created XSLT file for Sitemaps. Petr Snobelts solution worked perfectly for me!
I got time-outs on the sitemap, which I only found out after opening it on the server itself. Before 4.7 (I just upgraded this particular site from 4.0.4.2), everything was still OK, so I'm trying to find out what's going on here... Just downloaded the 4.7.0 source.
I've done a lot of digging, and it seems to be certain bits if the sitemap throw a wobble if they have a number or a date in them.
For example, if you put @nodeName in the <lastmod> node, it renders super quick. Same for any other string based property. However, try it with @createDate, @updateDate or @level and it slows to a crawl. Casting the date to a string using string(@updateDate) doesn't fix it. However, outputting a literal string character after the node or url element (either a tab or a carriage return) seems to solve the issue. This is what Petr's solution does, albeit in the lastmod node. However, adding
<xsl:text> </xsl:text>
Underneath the closing </url> in the Macro seems to work too (and doesn't shove a huge gap after the date/time).
It's odd that it works fine on some sites, but on others it falls over like this. We're currently investigating whether this is caused by an XSLT Extension or similar from a 3rd party datatype. The components that are on our affected sites that aren't on the ones that work are:
uComponents
Embedded Content
Google Analytics
DocType Extensions
Can anyone else who is having this issue post a list of what extensions they're running?
Slow XSLT for Sitemap
Hi
I have the following docuemtn type structure
master
-homePage
-textPage
-aboutUs
-admissions
-contactUs
-etc...
I want to list all level1 nodes and all level2 nodes and have this working but it is horrible slow (2 seconds). Anyone know how to make this more efficient?
Cheers
J
Hey,
Haven't looked through the code, but obviously if you turn caching on the macro even for a few seconds it'll make a huge difference.
Rich
Perfect
Ta very much
Julian
I'm experiencing similar problem using the code below;
However, I've tracked it down that when @updateDate (lastmod) is removed, performance is as would be expected. It seems that loading in either @updateDate or @createDate is causing huge performance issues.
This ghastly situation makes no sense at all. My head hurts and I am confused.
Lau
* also why format the date, when its in the correct format anyway?
(this performance issue is only noticable on sites with say around 500 nodes)
Avg. Time with @updateDate = 8 second, without 0.25 seconds.
(I plan on refactoring the XSLT, and make it use match templates properly, which will improve performance too)
I have same issue and find out it can be solved by using this chunk of code:
Note that all chunk can't be on one line.
Petr
Brilliant Petr, problem solved.
Do you have any idea why this is happening, is the field being read as invalid by the XSLT processor?
That makes no sense at al?! Weird....
By the way, a better way to write that lastmode would be:
That way, the +00 won't drop down to the next line when you format the xslt in visual studio.
The date won't always be formatted correctly when different locale's are used, so that's why I put in the formatting. Are you sure it's not the formatdatetime that has the perf issue?
Hi Laurence, I have no idea why this is happening, I just find first workaround.
I also want to know if it's caused by xslt processor or by umbraco, but I have not time to explore it more.
P.
It is very odd indeed!
I had orginally thought the issue was with the umbraco:format-date-time,
umbraco:format-date - 8 seconds
exslt:format-date - 8 seconds
@updateDate - 8 seconds
@update />+00:00 - 0.25 second
Weird.
Hi Sebastiaan,
In my case it is not caused by formating, because it is slow also if I put my code to one line.
Just want to chime in that I was having the exact same performance problem in my self-created XSLT file for Sitemaps. Petr Snobelts solution worked perfectly for me!
I got time-outs on the sitemap, which I only found out after opening it on the server itself. Before 4.7 (I just upgraded this particular site from 4.0.4.2), everything was still OK, so I'm trying to find out what's going on here... Just downloaded the 4.7.0 source.
Keep us posted on what you find, would be good to get to the bottom of this one (:
I am experiencing the exact same issue as you Thijs, one site was v 4.0.3 to 4.7 and the other was 4.5 to 4.7 both have the same issue.
I have done a little digging and found some strange issues
this doesn't work:
However the following will work
Notice the extra forward slash on the line
I happen to haver this issue with Umbraco support so will keep you posted to there solution.
I've had this on a few sites recently, see post here: http://our.umbraco.org/forum/developers/xslt/23767-Sitemap-Macro-Running-Slow
I've done a lot of digging, and it seems to be certain bits if the sitemap throw a wobble if they have a number or a date in them.
For example, if you put @nodeName in the <lastmod> node, it renders super quick. Same for any other string based property. However, try it with @createDate, @updateDate or @level and it slows to a crawl. Casting the date to a string using string(@updateDate) doesn't fix it. However, outputting a literal string character after the node or url element (either a tab or a carriage return) seems to solve the issue. This is what Petr's solution does, albeit in the lastmod node. However, adding
<xsl:text>
</xsl:text>
Underneath the closing </url> in the Macro seems to work too (and doesn't shove a huge gap after the date/time).
It's odd that it works fine on some sites, but on others it falls over like this. We're currently investigating whether this is caused by an XSLT Extension or similar from a 3rd party datatype. The components that are on our affected sites that aren't on the ones that work are:
Can anyone else who is having this issue post a list of what extensions they're running?
is working on a reply...