Copied to clipboard

Flag this post as spam?

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

  • jacob phillips 130 posts 372 karma points
    Apr 04, 2014 @ 02:33
    jacob phillips

    filter relations

    Given an id, I get some relations:

    <xsl:variable name="relations" select="umbraco.library:GetRelatedNodesAsXml(@id)//relation"/>

    When I look at them using copy-of, I see they are there:

    <xsl:copy-of select="$relations" />


    <relation childid="1485" parentid="8530" createdate="8/13/2013 10:00:35 PM" typename="Author" typeid="8">
        <node id="1485" path="-1,1087,1326,1331,1485" nodename="Bob Moffitt" createdate="2012-12-14T14:54:21" sortorder="25" writerid="0" level="4" parentid="1331"></node>
    <relation childid="8531" parentid="8530" createdate="8/13/2013 10:08:11 PM" typename="PrimaryImage" typeid="2">
        <node id="8531" path="-1,1109,1874,7841,8531" nodename="0813 bm regional transit" createdate="2013-08-13T22:06:16" sortorder="0" writerid="32" level="4" parentid="7841"></node>
    <relation childid="8534" parentid="8530" createdate="8/13/2013 10:27:24 PM" typename="RotatorImage" typeid="3">
        <node id="8534" path="-1,1109,1874,7841,8534" nodename="Regional Transit Bus rotator" createdate="2013-08-13T22:27:11" sortorder="0" writerid="3" level="4" parentid="7841"></node>

    What I want to be able to do, is just use a filter to get all of the Author relations, like this (this isn't working):

    <xsl:variable name="relations" select="umbraco.library:GetRelatedNodesAsXml(@id)//relation[@typename='Author']"/>

    I've tried a few different things, like putting the string 'Author' in a variable, so that it's

        <xsl:variable name="Author" select="Author" />
    <xsl:variable name="relations" select="umbraco.library:GetRelatedNodesAsXml(@id)//relation[@typename=$Author]"/>

    Then I could get to my Author's name (in the node element, property @nodename). Most of the time it's just one Author relations, but sometimes, there are two.

    Maybe like this...

    <xsl:for-each select="$relations">
    <xsl:value-of select="./node/@nodename"/>

    But I get nothing as soon as I put the [@typename='Author'] on my relations variable.

    How can I do it? Thanks for looking.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Apr 04, 2014 @ 05:49
    Chriztian Steinmeier

    Hi Jacob,

    If I'm not mistaken, it looks like you need to put your copy-of inside a <textarea> - the XML you've got seems to have been lowercased by the visualizer.

    The first thing you tried should work, but I'm pretty sure that @typename follows the conventions and thus have a capital N - @typeName

    Hope that's it,


  • jacob phillips 130 posts 372 karma points
    Apr 04, 2014 @ 07:02
    jacob phillips

    Yeah, it was. I never would have guessed that. Thanks.

Please Sign in or register to post replies

Write your reply to: