Copied to clipboard

Flag this post as spam?

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


  • Rune Grønkjær 1372 posts 3103 karma points
    Feb 14, 2011 @ 11:56
    Rune Grønkjær
    0

    apply-templates and GetXmlNodeById

    I have found a weird problem when trying to use apply-templates and GetXmlNodeById. When running the code below the xslt cannot be saved, say umbraco. There are no errors in my xslt and the page works perfectly if I save and "ignore errors".

    <xsl:apply-templates select="umbraco.library:GetXmlNodeById('pageId')" />

    Why is it doing this?

    /Rune

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Feb 14, 2011 @ 13:24
    Lee Kelleher
    2

    Hi Rune,

    The reason the XSLT editor (in the Umbraco back-office) is showing an error is because the parser doesn't know that "pageId" is numeric (or even holds a value).

    If you wrap a condition around the apply-templates, then the XSLT editor will be happier:

    <xsl:if test="'pageId' &gt; 0>
        <xsl:apply-templates select="umbraco.library:GetXmlNodeById('pageId')" />
    </xsl:if>

    Obviously replace 'pageId' with the correct property/attribute/value.

    Like you say, the XSLT is still perfectly valid (and works) ... so its up to you whether you want to keep the XSLT editor happy? ;-)

    Cheers, Lee.

  • Rune Grønkjær 1372 posts 3103 karma points
    Feb 14, 2011 @ 14:26
    Rune Grønkjær
    0

    Super. That took care of that problem. Thanks man.

    /Rune

  • 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