Question about the syntax for queries

Sauveen:

The "00" spec. has

 <!ELEMENT and    (expr+) >
 <!ELEMENT or     (expr+) >

to define the syntax for "and" and "or" expressions. 
However, "and" and "or" are binary operators
(which we would like to extend to be n-ary operators, 
since they are associative and commutative). 
My understanding of "+" in XML is that it means 
"one or more". So, the way I read the above
syntax is that it allows an "and" expression to have
one operand. For example,

<d:and> 
    <d:term>
        <d:lt>
            <d:value> 
                <d:prop>X</d:prop>
            </d:value>
            <d:value>
                <d:literal>1</d:literal>
            </d:value>
        </d:lt> 
    </d:term
</d:and>

or, translating into the usual mathematical
notation, "AND X > 1".

However, "and" is not a unary operator, i.e., it takes 
at least two operands. So, shouldn't the syntax be

 <!ELEMENT and    (expr, expr+) >
 <!ELEMENT or     (expr, expr+) >

to force at least two operands for "and" and "or"?

Now, I realize that we could extend "and" and
"or" to unary operators by defining them to be
the identity operator if they have just one operand.
However, I would oppose that, as it would not be
doing a favor to any implementer translating
the XML query expression into SQL or whatever
he needs to translate it to. The implementer would have to 
make a special case out of that, but nothing
is gained for the effort. I would rather have
unary "and" and "or" operators be illegal
syntax by using the revised syntax shown above.

I'm new to XML, so I may have missed the point,
so, what are your comments?

Alan Babich

Received on Friday, 17 April 1998 16:14:12 UTC