Filtering one set of elements based on another

Discussion in 'XML' started by RogerTBrick, Mar 3, 2005.

  1. RogerTBrick

    RogerTBrick Guest

    This is probably dead simple - but it's getting late and I've be
    staring at XSL for waaaay to long!

    I have an XML file that basically contains two lists:
    <root>
    ...
    <list name="allItems">
    <value>A</value>
    <value>B</value>
    <value>C</value>
    </list>
    <list name="exclude">
    <value>A</value>
    </list>
    ...
    </root>

    I want to be able to select all the value elements from the "allItems"
    list that are NOT in the "exclude" list. I have soft-of-a solution
    involving a few templates and if statements - yet I'm sure there's an
    elegant way to do this with XPath, but I can't think of it.

    And it's beginning to do my head in.

    Cheers,

    Jason "My head hurts" Irwin.
    RogerTBrick, Mar 3, 2005
    #1
    1. Advertising


  2. > I want to be able to select all the value elements from the "allItems"
    > list that are NOT in the "exclude" list.



    select="list[@name='allItems']/value[not(.=../../list[@name='exclude']/value)]"

    David
    David Carlisle, Mar 3, 2005
    #2
    1. Advertising

  3. RogerTBrick

    RogerTBrick Guest

    David Carlisle <> wrote in message news:<>...
    > select="list[@name='allItems']/value[not(.=../../list[@name='exclude']/value)]"

    AH! Thank you!

    JI
    RogerTBrick, Mar 4, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. loveNUNO
    Replies:
    2
    Views:
    884
    loveNUNO
    Nov 20, 2003
  2. Adam Hartshorne
    Replies:
    2
    Views:
    359
    Nitin Motgi
    Jan 27, 2006
  3. Ted
    Replies:
    0
    Views:
    119
  4. Robert Cohen
    Replies:
    3
    Views:
    246
    Andrew Durstewitz
    Jul 15, 2003
  5. ten8ciousb
    Replies:
    7
    Views:
    124
    Thomas 'PointedEars' Lahn
    Jan 26, 2009
Loading...

Share This Page