Copied to clipboard

Flag this post as spam?

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


  • Tom Maton 387 posts 659 karma points
    Aug 02, 2010 @ 13:49
    Tom Maton
    0

    Getting value in xslt from node in 4.5.1

    Hi All,

    I've just upgraded a site to 4.5.1 and as I'm getting used to the new schema I used the add value-of functionto make sure it was correct. So I got this returned:

    <xsl:value-of select="leftContentLink"/>

    Thinking this would work, but nothing was being returned, so i modified it to do

    <xsl:value-of select="$currentPage/leftContentLink"/>

    And it works, hay-presto!!

    My Question is surely if your using the "Insert value-of" into your xslt it should append the $currentPage to the beginning of the alias? Just like in version 4.0.3 does with data?

    Thanks

    Tom

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Aug 02, 2010 @ 14:39
    Lee Kelleher
    2

    Hi Tom,

    There is no difference how the XSLT/XPath selects the nodeset between v4.0.x and v4.5 - the only thing that matters is the context.

    Usually when you need to output any of the property data (which was "data[@alias='propertyAlias']" in the legacy XML schema), you were usually in a for-each loop (or apply-templates) - so the current() node had the context.  The same still applied to the new v4.5 XML schema.

    For example, you can loop through the content nodes - and the context of the node is within the loop, so it doesn't need to be prefixed with anything.

    <xsl:for-each select="$currentPage/*[@isDoc]">
        <xsl:value-of select="propertyAlias" /><!-- this used to be data[@alias='propertyAlias'] -->
    </xsl:for-each>

    The reason why "leftContentLink" doesn't work on its own, is because there is no context to the data/value.  Whereas when you use "$currentPage/leftContentLink", the XSLT knows to look-up the value from "$currentPage".

    Cheers, Lee.

  • Tom Maton 387 posts 659 karma points
    Aug 02, 2010 @ 14:44
    Tom Maton
    0

    Thanks for clearing that up Lee, makes more sense now

    Cheers

    Tom

  • sun 403 posts 395 karma points
    Aug 02, 2010 @ 15:19
    sun
    0

    Just tell xslt where to start.

  • 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