Copied to clipboard

Flag this post as spam?

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


  • Brian Andersen 35 posts 66 karma points
    Nov 23, 2010 @ 23:23
    Brian Andersen
    0

    get nodename in xslt

    This should be an easy one:

    I am trying to check for a nodename like this: 

    <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc and @nodeName='nicename']">

    do something

    </xsl:if>

     

    I find a lot of sample showing that i can use;

     

    @nodeName = 'peoples'

    But that does not work anymore so it seems. 
    If i use @id then it works, but i want to use the name. Anyone?
    
    Thanks! :)

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Nov 23, 2010 @ 23:47
    Kim Andersen
    0

    Hi Brian

    The code that you provided above should work, if you are using the new XML schema and you have a node with a node name of nicename. But remember that the name is casesensitive.

    I have just tested your code on a v4.5.2, and it outputs the content in the if-statement if I'm on a page that has a parent or ancestor with the name that I provided in the select.

    Could you double check that you have spelled the name right.

    /Kim A

  • Brian Andersen 35 posts 66 karma points
    Nov 23, 2010 @ 23:59
    Brian Andersen
    0

    Ah yes. it was "Nicename" not "nicename". 

    Thanks alot for clearing it up for me, I thought the syntax had changed.

    /Brian

  • Kim Andersen 1447 posts 2196 karma points MVP
    Nov 24, 2010 @ 00:28
    Kim Andersen
    0

    Hehe, that's okay :) One of those mistakes that easy to make. But now you'll probably not make this excact "mistake" so many times in the future :D

    Glad it worked out for you.

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft