Copied to clipboard

Flag this post as spam?

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


  • Streety 358 posts 567 karma points
    Feb 13, 2012 @ 14:07
    Streety
    0

    Getting the values from an Ultimate Picker recursively

    Hello I have an ultimate picker control pointing to a node so that I can select items to display. This work fine.

    However when I load a page that is a subordinate of the root the XSLT throws an error:

    Error parsing XSLT file: \xslt\[XSLT]FooterLinks.xslt

    Presumably because the variable:

    <xsl:variable name="nodeIds" select="umbraco.library:Split($currentPage/footerLinks,',')" />

    Returns nothing.

    My question is how can I mod the syntax to look at the current node or look at the node above? I think this can be done but can't fanthom the syntax.

     

     

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Feb 13, 2012 @ 21:25
    Chriztian Steinmeier
    2

    Hi Streety,

    This is how you pick recursively in XSLT:

    <!-- Grab the footerLinks property recursively -->
    <xsl:variable name="footerLinks" select="$currentPage/ancestor-or-self::*[normalize-space(footerLinks)][1]/footerLinks" />
    <xsl:variable name="nodeIds" select="umbraco.library:Split($footerLinks, ',')" />
    

    /Chriztian

  • Streety 358 posts 567 karma points
    Feb 14, 2012 @ 10:49
    Streety
    0

    Woah! That worked. You the man!

     

    I get:

    <xsl:variablename="footerLinks"select="$currentPage/ancestor-or-self::

    But

    *[normalize-space(footerLinks)][1]/footerLinks"/>
    Ehh! What the [1] doing and normalize-space?

     

    Thank you.

     

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Feb 14, 2012 @ 14:58
    Chriztian Steinmeier
    1

    Hi Streety,

    As you may know, ancestor-or-self:: returns all the ancestors that match the specified node name (in this case the wildcard "*") - here's a sample in the Axes Visualizer ...

    The normalize-space() function collapses all whitespace in a text node (leaving it blank if it consists of only whitespace), so the immediately following predicate [normalize-space(footerLinks)] makes sure that out of the nodes returned from the axis, we only want the ones that actually have a value in the footerLinks property. The last predicate ([1]) returns only the first node in the resulting set, which will be $currentPage itself, its parent, the parent's parent etc.

    Having arrived at a single node guaranteed to have a value in the footerLinks property, we finally end the XPath by selecting that property.

    /Chriztian

  • Streety 358 posts 567 karma points
    Feb 14, 2012 @ 15:50
    Streety
    0

    Thank you again for responding. The Axes Simulator is a wonderul learning tool.

  • 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