Re: Please add RDF term checking operators to sparql

On Tue, 2005-01-25 at 10:36 +0000, Dave Beckett wrote:
> I think these would be useful operators for value testing of SPARQL
> RDF Terms, to go along with lang() and dtype()* operating on
> literal terms.

Hmmm... these make me uneasy about use/mention issues.
It seems to me that functions should take as input
the denotation of the terms, not the syntax of the terms.

In C, you can't write a function

  int lastDigitIsZero(float arg){ ... }

because when it's called, it will see the same
value in both cases:


This is what makes me uneasy about the str() function;
I'd rather that str(<>)
be specified to relate class to a string, not a URI to a string.

Consider a service that offers queries over the
OWL closure of...

  <orglist#w3c> cyc:age [ :inYears <w3cstats#ageInYears>].
  <w3cstats#ageInYears> owl:sameAs 10.

and a query...

  WHERE (?ORG cyc:age ?DUR)
         (?DUR :inYears ?QTY)
   AND ?QTY > 5.

Hmm... I don't think this example makes my point, because
the OWL closure will include

  <orglist#w3c> cyc:age [ :inYears 12].

I have been uneasy about this for some time, but I can't seem
to construct an example that makes the point sharply, so
maybe there is no issue. But I'm still worried.

And yes, my worry applies to dtype() and lang() as well.

> I propose adding to 10.2 10.2 Value Testing / RDF Types
> possibly a new section or could be in one of the existing ones:
> 10.2.3 SPARQL Operations on RDF Terms
> The following table provides operations to test if an expression is
> one of the three RDF Terms[#href to definition in section 2.2].
> Operator: isblank(arg)
> Meaning: Tests if the expression is an RDF blank node
>                 ( )
> Return: xsd:boolean
>   isblank(_:a)       => true
>   isblank(<uri>)     => false
>   isblank("literal") => false
> Operator: isuri(arg)
> Meaning: Tests if the expression is an RDF URI Reference 
>               ( )
> Return: xsd:boolean
>   isuri(<uri>)     => true
>   isuri(_:blank)   => false
>   isuri("literal") => false
>   [ could be isresource() but then they are all RDF resources

Well, they all denote resources. And if you consider terms
to be resources, then yes, they're resources. But I think
you made a use/mention think-o there.

> Operator: isliteral(arg)
> Meaning: Tests if the expression is an RDF Literal
>                ( )
> Return: xsd:boolean
>   isliteral(<uri>)     => true
>   isliteral(_:blank)   => false
>   isliteral("literal") => true
> Examples of use
> Find literals in French
>   SELECT ?z
>   WHERE (?x ?y ?z)
>   AND isLiteral(?z) and lang(?z) = "fr"
> Find blank subject nodes
>   SELECT ?x
>   WHERE (?x ?y ?z)
>   AND isBlank(?x)
> Find triples with URIs
>   SELECT ?x
>   WHERE (?x ?y ?z)
>   AND isURI(?z)
> Dave
> * Yuck - datatype() is a full word for 3 chars more and we have rdf:datatype
> lang() is OK since xml:lang has lots of use
Dan Connolly, W3C
D3C2 887B 0F92 6005 C541  0875 0F91 96DE 6E52 C29E

Received on Tuesday, 25 January 2005 14:49:05 UTC