Copied to clipboard

Flag this post as spam?

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


  • Richard 146 posts 168 karma points
    Aug 16, 2010 @ 10:33
    Richard
    0

    GetXmlNodeById caused hanging

    This is a cautionary tale in the use of umbraco.library:GetXmlNodeById(@link), with Umbraco 4.0.4.1

    I found an issue on a site I was creating, where the document type was using the "Related Links" property. The page chosen was then deleted, the following code then hung, the server starting a dw20.exe process which consumed about 50% cpu.

    <xsl:variable name="linkPage" select="umbraco.library:GetXmlNodeById(@link)"/>

    <xsl:variable name="image" select="umbraco.library:GetMedia($linkPage/data [@alias = 'listImage'],0)" />
    <img src="{$image/data[@alias = 'umbracoFile']}" height="{$image/data[@alias = 'umbracoHeight']}" width="{$image/data[@alias = 'umbracoWidth']}" />
    <xsl:value-of select="$linkPage/data [@alias='pageTitle']" />

    So the XSLT was changed to the following, which worked without an issue

    <!-- This returns <node> XML, use mode to ensure we do not match another template match
    <xsl:apply-templates select="umbraco.library:GetXmlNodeById(@link)" mode="study" />

    <!-- This is not necessary, but would be called if the node id @link is not published -->
    <xsl:template match="error" mode="study">
    <!-- Oops: <xsl:value-of select="."/> -->
    </xsl:template>

    <xsl:template match="node" mode="study">

    <xsl:if test="string-length(./data [@alias = 'listImage']) &gt; 0">
    <xsl:variable name="image" select="umbraco.library:GetMedia(./data [@alias = 'listImage'],0)" />
    <img src="{$image/data[@alias = 'umbracoFile']}" height="{$image/data[@alias = 'umbracoHeight']}" width="{$image/data[@alias = 'umbracoWidth']}" />
    </xsl:if>
    <xsl:value-of select="./data [@alias='pageTitle']" />

    </xsl:template>
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies