[sc34wg3] TMQL: Operators "Not equal"

Robert Barta rho at devc.at
Mon Oct 29 08:46:05 EDT 2007


On Mon, Oct 29, 2007 at 11:42:07AM +0100, Inge Henriksen wrote:
> How will different Unicode characters be handled when it comes to
> comparing? When see the "==" operator I assume a binary comparison, but
> should these kinds of operators be used when comparing text's? If you
> say 
> 
>   select $p / name
>   where
>      $p isa person
>   &  $p / homepage == "http://myspace.com/"

First observation: the == is based on binary comparison of literal
values. But left and right to == there can be lists of values
(actually it is more general than that):

    select $p / name, $q / name
    where
       $p isa person
    &  $q isa person
    &  $p <- author == $q <- author

This finds all two people how have authored something together.

> where each side of the operator is of a different Unicode character set
> then they are not binary equal but they may still be equal from a
> culture-insensitive standpoint. In addition "http://myspace.com/" and
> "HTTP:/MYSPACE.COM/" are also not equal from a binary comparison
> standpoint, but are equal from a case-insensitive standpoint.

Second observation: What it exactly means that two literals are
regarded to be "equal" is another question. TMQL defines strings and
uses character comparison. Here

   "http://myspace.com/"

is not the same as

   "HTTP:/MYSPACE.COM/"

If you want that to be equal, then your TMQL processor has to define a
new datatype, say, 'culture-sensitive' and has to define equality on
it. This is then completely transparent to TMQL itself.

So your example

>   select $p / name
>   where
>      $p isa person
>   &  $p / homepage equals "http://myspace.com/"

becomes

select $p / name
where
    $p isa person
 &  $p / homepage == "http://myspace.com/"^^my:culture-sensitive

> Please forgive me if this has been discussed before and I have missed it
> :)

I never forgive. But I forget. :-)

\rho

> To: Discussion of ISO/IEC 13250 Topic Maps
> Subject: Re: [sc34wg3] TMQL: Operators "Not equal"
> 
> On Fri, Oct 26, 2007 at 05:22:25PM +0200, Lars Heuer wrote:
> > The current draft lacks of a not equal operator, like "!=". Is that
> > intentional?
> > 
> > A not equal operator is quite handy even if
> > 
> >        not(1.0 = 2.0)
> > 
> > works, though.
> 
> Careful here: 
> 
> '==' has 'exists semantics' as it is operating on sequences! So 
> 
>   select $p / name
>   where
>      $p isa person
>   &  $p / homepage != "http://myspace.com/"
> 
> might not really signal what is going on. If I read the above quickly,
> then I would select all persons which have not a homepage at MySpace.
> 
> But what it means is
> 
>   not ($p / homepage == "http://myspace.com/")
> 
> So I'm actually asking for all persons where it is
> 
>   "not true, that there is at least one MySpace homepage"
> 
> The proposed notation
> 
>   $p / homepage != "http://myspace.com/"
> 
> would more indicate
> 
>   "no homepage is on MySpace"
> 
> This is also the reason to prefer '==' over '=', because the query
> author should keep that in mind.
> 
> \rho
> -- 
> And then he said: "You should read my blog." http://kill.devc.at/
> _______________________________________________
> sc34wg3 mailing list
> sc34wg3 at isotopicmaps.org
> http://www.isotopicmaps.org/mailman/listinfo/sc34wg3
> 

-- 
And then he said: "You should read my blog." http://kill.devc.at/


More information about the sc34wg3 mailing list