0

I'm trying to use the following code to filter out xml return tags that do not contain a given status code:

l_xml_return := (xmltype(l_xml_response).extract('//return[not(issueStatusId=84388)]|
                                                                      //return[not(issueStatusId=73630)]|
                                                                      //return[not(issueStatusId=67539)]|
                                                                      //return[not(issueStatusId=42527)]|
                                                                      //return[not(issueStatusId=22702)]|
                                                                      //return[not(issueStatusId=20643)]|
                                                                      //return[not(issueStatusId=4368)]|
                                                                      //return[not(issueStatusId=4363)]|
                                                                      //return[not(issueStatusId=4364)]
                                                                     ').getclobval());

My xml is comprised of the following:

<results>
  <return>
    <issueStatusId>84388</issueStatusId>
    <name>Test 1</name>
  </return>
  <return>
    <issueStatusId>4364</issueStatusId>
    <name>Test 2</name>
  </return>
  <return>
    <issueStatusId>999999</issueStatusId>
    <name>Test 3</name>
  </return>
</results>

With this xml code and xpath statement, only the return tag with an issue status of 999999 should be returned however this is not the case.

Does anyone know why this is?

Cheers,

Jezzipin

1 Answer 1

2

From XPath 1.0 specs

The | operator computes the union of its operands, which must be node-sets.

Whereas you need the intersection of these multiple //return[not(...)]

You can use and on multiple not() conditions as a predicate

//return[
    not(issueStatusId=84388) and
    not(issueStatusId=73630) and
    not(issueStatusId=67539) and
    not(issueStatusId=42527) and
    not(issueStatusId=22702) and
    not(issueStatusId=20643) and
    not(issueStatusId=4368) and
    not(issueStatusId=4363) and
    not(issueStatusId=4364)]

Or equivalently:

//return[
    not(
        issueStatusId=84388 or
        issueStatusId=73630 or
        issueStatusId=67539 or
        issueStatusId=42527 or
        issueStatusId=22702 or
        issueStatusId=20643 or
        issueStatusId=4368 or
        issueStatusId=4363 or
        issueStatusId=4364
        )
    ]
Sign up to request clarification or add additional context in comments.

2 Comments

+1 for last one.. :)
Great thanks. The last one was what I need. Sadly W3CSCHOOLS information on XPATH is a bit lacking and I don't really use XML all the much so wasn't sure if there was an or operator or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.