cancel
Showing results for 
Search instead for 
Did you mean: 

Are XPath "qualifiers" limited to equality tests?

VolkerBarth
Contributor
5,945

A question similar to this one..

When using a predicate in a XPath query to test for a particular predicate (which is called a "qualifier" in the docs), am I limited to equality tests?

Equality tests like '//[EmployeeID="105"]' do work in my tests.

However, tests with "<=" or "!=" or combining predicates with " and " etc. do not work and raise syntax errors.

IMHO, the docs are a bit unclear (or my understanding of the term "expression" is too general here), stating that

Qualifiers of the form expr1[expr2] and expr1[expr2="string" ] can be used, where expr2 is any supported XPath expression. A qualifier evaluates TRUE if expr2 matches one or more nodes. For example, 'a[b]' finds a nodes that have at least one b child, and a[b="I"] finds a nodes that have at least one b child with a text value of I.

Again, the obvious workaround would be to defer these tests after the openxml() result set is built, and filter the result set with common WHERE conditions.

The drawback might be (but I'm not sure) that this is possibly less efficient.

VolkerBarth
Contributor
0 Kudos

Any more insights would still be appreciated:)

Accepted Solutions (1)

Accepted Solutions (1)

jeff_albion
Advisor
Advisor

or my understanding of the term "expression" is too general here)

Actually I think the issue here is the part where we add "supported XPath expression" to the definition, and we say in the paragraph before:

"The openxml system procedure supports a subset of the XPath syntax, as follows:"

Ultimately meaning that we do not support all XPath expressions / operators - including any non-equality operators. So yes, equality is the only test you can add to the OPENXML XPath qualifier.


As per my answer over here, I have now made an enhancement request to look at further potential support for XPath queries in OPENXML (set operations, and boolean/comparison/set expressions) in CR #740332 for a future version of SQL Anywhere.

VolkerBarth
Contributor
0 Kudos

OK, yes, I've not noticed the self-reference to "supported XPath" expressions... - thanks for the clarification.

Answers (0)