Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[higgins-dev] [IdAS] filter language: XPath/SPARQL


I've been thinking about the filter language, and (as usual) have come up with more questions than answers. My plan was to use the recently-posted Example Ontology (http://spwiki.editme.com/ExampleContextOntology) as a springboard to compare XPath expressions and SPARQL expressions. Didn't quite get there...

For the following discussion, I will ONLY be considering the filter used in Context.getSubjects(filter).
-----
Question 1: Is the filter expression intended to apply to (a) the entire Context (i.e., the result of the filter should be the set of DigitalSubjects that match), or (b) to a DigitalSubject (i.e., look at each DigSub and add it to the list if the filter is true)?

If (a) then we might have matches to nodes (objects) that aren't DigSubs. If (b), we can't take advantage of SPARQL expressions that let you control the ordering, number, etc., of the results. Going forward, I'll assume that it's (b).


-----
Question 2: Is there a canonical RDF/XML representation of any given RDF graph? The Primer (http://www.w3.org/TR/rdf-primer/) lists many abbreviations that can be used, and so there are many possible XML representation of a given graph. For example, let's assume that the example Person type only has two elements: firstname and surname. The subject could be represented either as:

<rdf:Description rdf:about="urn:jim-sermersheim">
      <jim:firstname>Jim</jim:firstname>
</rdf:Description>

<rdf:Description rdf:about="urn:jim-sermersheim">
      <jim:surname>Sermersheim</jim:surname>
</ref:Description>

Or as the following:

<rdf:Description rdf:about="urn:jim-sermersheim">
      <jim:firstname>Jim</jim:firstname>
      <jim:surname>Sermersheim</jim:surname>
</ref:Description>

In the second case, an XPath expression '.[jim:firstname="Jim" and jim:surname="Sermersheim"]' would work, but in the first case it wouldn't. (I apologize if I don't get the XPath syntax quite right -- I'm a newbie.) Is there a way to handle the first case in XPath? If the "canonical" RDF/XML representation combines all nodes with the same rdf:about attribute, then maybe this is OK.

In both cases, the following SPARQL query would be fine: { ?x jim:firstname "Jim" . ?x jim:surname "Sermersheim" }.

Another case is the representation of type. In Paul's example, we say that urn:jim-sermersheim is a Person as follows:

<rdf:Description rdf:about="urn:jim-sermersheim">
      ...
      <rdf:type>
            <rdf:Description rdf:about="&jim;Person>
      </rdf:type>
</rdf:Description>

But in the Primer, they tend to use the following:

<rdf:Description rdf:about="urn:jim-sermersheim">
      ...
      <rdf:type rdf:resource="http://www.novell.com/jim#Person"; />
</rdf:Description>


In one case the type is an element, and in the other it's an attribute. How would you use XPath in this case?


-----
Question 3: In the example, hasPostalAddress is a separate object. The postal address information is not an XML descendent of the jim-sermersheim node, and there's no link back to the jim-sermersheim node from the jims-address node.

Given this schema, how would one search for all DigSubs from a particular city?

In SPARQL, you'd say: { ?x jim:hasPostalAddress ?addr . ?addr jim:city "Provo" }.

Is there a way to do this in XPath? I wasn't able to figure it out, based on my limited research.




Back to the top