does xml element exist, regardless of value?
Try this:

For attributes

SELECT COUNT(x.a2) cnt_a2, COUNT(x.a4) cnt_a4
FROM
(
VALUES 
  '&lt;doc&gt;&lt;a&gt;&lt;b a2=""&gt;&lt;c a2=""/&gt;&lt;/b&gt;&lt;/a&gt;&lt;/doc&gt;'
, '&lt;doc&gt;&lt;a&gt;&lt;b a3=""/&gt;&lt;/a&gt;&lt;/doc&gt;'
) T (D)
, XMLTABLE
(
  '$doc' PASSING XMLPARSE(DOCUMENT T.D) AS "doc"
  COLUMNS
    a2 XML PATH '//*[fn:exists(@a2)]'
  , a4 XML PATH '//*[fn:exists(@a4)]'
) X 
WHERE 
--XMLEXISTS('$doc//*[@a4 or @a5]' PASSING XMLPARSE(DOCUMENT T.D) AS "doc")
XMLEXISTS('$doc//*[@a2 or @a4]' PASSING XMLPARSE(DOCUMENT T.D) AS "doc")
;


The result is:

|CNT_A2     |CNT_A4     |
|-----------|-----------|
|1          |0          |


For elements with namespaces

SELECT COUNT(x.code1) cnt_code1, COUNT(x.code3) cnt_code3
FROM
(
VALUES 
  '&lt;doc xmlns:conditionmessage="http://xyz.com"&gt;&lt;conditionmessage:code1&gt;MYCODE&lt;/conditionmessage:code1&gt;&lt;/doc&gt;'
, '&lt;doc xmlns:conditionmessage="http://xyz.com"&gt;&lt;conditionmessage:code2&gt;MYCODE&lt;/conditionmessage:code2&gt;&lt;/doc&gt;'
) T (D)
, XMLTABLE
(
  XMLNAMESPACES('http://xyz.com' AS "conditionmessage"), '$doc' PASSING XMLPARSE(DOCUMENT T.D) AS "doc"
  COLUMNS
    code1 XML PATH '//*[fn:exists(conditionmessage:code1)]'
  , code3 XML PATH '//*[fn:exists(conditionmessage:code3)]'
) X
WHERE XMLEXISTS('declare namespace conditionmessage = "http://xyz.com"; $doc//*[conditionmessage:code1 or conditionmessage:code3]' PASSING XMLPARSE(DOCUMENT T.D) AS "doc");


The result is:

|CNT_CODE1  |CNT_CODE3  |
|-----------|-----------|
|1          |0          |