Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
253
XQuery Comparison Expressions
This group of expressions is used to compare two values. XQuery supports four
types of comparison expressions: value comparisons, general comparisons, node
comparisons, and order comparisons.
This xquery contains a conditional expression (see below for another
example), and checks if the first operand of the test expression is
greater than the second. This is the output:
<?xml version="1.0"?>
<compare>
<yes/>
</compare>
2. <str>
{
IF "right" = "left"
THEN <yes/>
ELSE <no/>
}
</str>
This xquery also contains a conditional expression, testing the
equality of two strings. This is the output:
<?xml version="1.0"?>
<str>
<no/>
</str>
3. <output>
{
IF 1234 >= 123
THEN <y>yes, its greater</y>
ELSE <n>no, its smaller</n>
}
</output>
This xquery compares two integer values, and outputs some XML on the
decision "yes" or "no". This is the output: