W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > July to September 2005

Re: writing a triple filter?

From: Kendall Clark <kendall@monkeyfist.com>
Date: Fri, 5 Aug 2005 17:31:25 -0400
To: Dan Connolly <connolly@w3.org>
Cc: DAWG Mailing List <public-rdf-dawg@w3.org>
Message-ID: <20050805213125.GB13474@monkeyfist.com>

On Fri, Aug 05, 2005 at 04:16:59PM -0500, Dan Connolly wrote:
> On Fri, 2005-08-05 at 15:02 -0400, Kendall Clark wrote:
> > Dogs,
> > 
> > How do I say, in a CONSTRUCT query, that if there's a triple T in the
> > solution set,
> 
> I can't parse that. Solution sets are made of bindings, not triples.

Right.

> >  I don't want it in the output graph? I thought something like
> > FILTER fn:not(T), but that doesn't work in the WHERE clause. But that
> > doesn't seem to be legal.
> > 
> > Do we have any functions that operate on triples?
> 
> I suspect what you want can be done with !bound(?v) gymnastics.
> 
> Can you give me a little more context?

Yes. I was wondering if not bound was the thing to do.

Context:

In the CONSTRUCT case, what I wanted to do was filter out all the triples
about knowing Edd Dumbill... Here's the data again:

--Data--
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix myfoaf: <http://clark.dallas.tx.us/kendall/foaf.rdf#>.

myfoaf:kendall foaf:name "Kendall Grant Clark";
               foaf:workplaceHomepage <http://www.mindswap.org/>;
               foaf:homepage <http://clark.dallas.tx.us/kendall/>;
               foaf:knows myfoaf:edd;
               foaf:knows myfoaf:niel;
	       rdf:type foaf:Person.

myfoaf:edd foaf:mbox <mailto:edd@usefulinc.com>;
	   rdf:type foaf:Person.

myfoaf:niel rdf:type foaf:Person;
	    foaf:mbox <mailto:niel@bornstein.atlanta.ga.us>.
----

I want to write a CONSTRUCT query that returns the FOAF file with some new
triples added about me and with the relation to myfoaf:edd removed. So, I
want results like this:

--Results--
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix myfoaf: <http://clark.dallas.tx.us/kendall/foaf.rdf#>.

myfoaf:kendall foaf:name "Kendall Grant Clark";
	       foaf:depiction <http://clark.dallas.tx.us/kendall/kendall.jpg>.
	       foaf:schoolHomepage <http://www.smu.edu/>.
               foaf:workplaceHomepage <http://www.mindswap.org/>;
               foaf:homepage <http://clark.dallas.tx.us/kendall/>;
               foaf:knows myfoaf:niel;
	       rdf:type foaf:Person.

myfoaf:niel rdf:type foaf:Person;
	    foaf:mbox <mailto:niel@bornstein.atlanta.ga.us>.
----
I wonder if this query works:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX myfoaf: <http://clark.dallas.tx.us/kendall/foaf.rdf#>

CONSTRUCT { myfoaf:kendall foaf:depiction <http://clark.dallas.tx.us/kendall/kendall.jpg>.
            myfoaf:kendall foaf:schoolHomepage <http://www.smu.edu/>.
	    myfoaf:kendall ?a ?b.
	    myfoaf:niel ?c ?d.
            }
WHERE { myfoaf:kendall ?a ?b.
        myfoaf:niel ?c ?d. }

Well, yes, that works, but with that query, I still get the pesky triple

      myfoaf:kendall foaf:knows myfoaf:edd
      
What I was looking for is a way to say that that ground triple should not be
included in the graph results. But, as Dave points out, we have no
operations that take triples, only ones that take terms of various kinds.

So can I say:

WHERE { myfoaf:kendall ?a ?b.
        myfoaf:niel ?c ?d.
	myfoaf:kendall ?e myfoaf:edd
	FILTER(fn:not(sop:isBound(?e))) }

Does that remove the pesky triple (myfoaf:kendall foaf:knows myfoaf:edd)? If
not, them I'm stumped and confused. If so, it seems like a sledgehammer,
when a turning fork is needed.

I'm pretty sure I can come up with a case where there are other triples that
match the bound pattern that I *don't* want to filter. I can't tell if I'm
trying to do something perverse (though, honestly, the use case seems like
it's in our problem domain: remove some people from my FOAF file and add
some new triples, returning the resulting graph); or whether there's another
way to do this altogether.

Cheers, 
Kendall
Received on Friday, 5 August 2005 21:33:38 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:24 GMT