Copied to clipboard

Flag this post as spam?

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


  • Nigel Wilson 944 posts 2076 karma points
    May 01, 2012 @ 20:11
    Nigel Wilson
    0

    xPath and Multiple Criteria For Node Selection

    Hi there

    I am working on some functionality for a photographic competition.

    I need to be able to identify entries to any competition with the following conditions:

    1. Judging is complete for the competition - a true/false property on the competition node.

    2. An email notification has not been sent to the entrant - a date picker property on the entry node. This node is 3 levels below the competition node.

    So I tried the following but it didn't work:

    var nodes = uQuery.GetNodesByXPath("//externalCompetition [@isDoc and competitionJudgingComplete = '1']//externalCompetitionEntry[@isDoc and resultNotification = '']");

    Can anyone suggest how this might be achieved ?

    Cheers

    Nigel

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    May 01, 2012 @ 20:17
    Lee Kelleher
    1

    Hi Nigel,

    Try wrapping "resultNotification" with a "string" function...

    string(resultNotification) = ''

    Cheers, Lee.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    May 01, 2012 @ 23:40
    Chriztian Steinmeier
    3

    Hi Nigel,

    Safest bet will be to use the normalize-space() function, like this:

    var nodes = uQuery.GetNodesByXPath("//externalCompetition[@isDoc and competitionJudgingComplete = 1]//externalCompetitionEntry[@isDoc and not(normalize-space(resultNotification))]");

    - you *can* take advantage of your knowledge of the aliases here to shorten this a bit (by getting rid of the @isDoc tests):

    var nodes = uQuery.GetNodesByXPath("//externalCompetition[competitionJudgingComplete = 1]//externalCompetitionEntry[not(normalize-space(resultNotification))]"); 

    - those are mostly needed in conjunction with the asterisk (e.g. *[@isDoc] ) - *unless*, of course, you're naming properties the same as doctypes (which you really shouldn't do anyway).  

    /Chriztian

  • Nigel Wilson 944 posts 2076 karma points
    May 02, 2012 @ 08:45
    Nigel Wilson
    0

    Hey chaps

    Wicked wicked wicked - high fives to you both.

    Lee - the string() function did in fact fix the problem.

    Chriztian - I hadn't heard of the normalize-space() function so have also used this - a bit more learning under the belt is always a good thing.

    You guys rock

    Nigel

Please Sign in or register to post replies

Write your reply to:

Draft