[Mulgara-dev] Mulgara 2.1.2

Paul Gearon gearon at ieee.org
Tue Aug 18 16:07:27 UTC 2009


On Tue, Aug 18, 2009 at 10:17 AM, Agustina Martinez<amgcia at gmail.com> wrote:
> Hi again,
>
> Regarding the last thing, "dc:type". You are totally right, dc:type is
> expecting literals so the values I get for the variable '?type' in my query
> are literals but when I create the construct template I am specifying as an
> object for the predicate "rdf:type" the values of the dc:type predicates. In
> this case I thought Mulgara would analyze the RDF namespace to construct an
> element rdf:type whose attribute is rdf:resource="some_uri" and in this case
> use the ?type value as an URI.

Why would you think this?

SPARQL is a pattern matching language. It has no knowledge of
semantics in its specification. You asked it for a literal and then
put that literal in the "object" position of a triple. This is exactly
what Mulgara did for you.

As for doing the above "analysis", then this has a lot of problems.
You're starting with a literal of "module". For a start, what URI
should be constructed that has this literal associated with it? Should
the URI look like "module" as well? If that's the case, then it's a
relative URI, so what is it relative to? Otherwise, what URI are you
referring to? Maybe it's a blank node? That would seem strange, but it
is legal.

Second, how would this class refer to the literal? By rdfs:label?
rdfs:comment? dcterms:description?

Finally, the triples you've asked for are actually valid RDF. Sure,
they are invalid RDFS, but that is a different issue. SPARQL CONSTRUCT
queries are able to build any kind of RDF, and are not required to
prevent you from shooting yourself in the foot if you try to create
invalid RDFS, OWL, or anything else.

> But instead is generating and rdf/xml tag as follows:
> <rdf:type>value_of_?type</rdf:type>

No, it's not value_of_?type, it's just ?type, which is exactly what
you asked for.

If you want something that refers to this literal, then ask for it
that way. For instance, you can modify the query to look for classes
that refer to your ?type variable as a label.

PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX rel: <info:fedora/fedora-system:def/relations-external#>
PREFIX ex: <http://www.example.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
CONSTRUCT {
  ?subject a ?type; ?p1 ?collection; ?p ?o.
}
FROM <rmi:/localhost/fedora#ri>
WHERE {
  {?subject <rel:isMemberOfCollection> ?collection.}
  UNION
  {?subject <rel:isPartOf> ?collection.}
  filter regex(str(?collection) , ".*moam:.*", "i")
  {
    ?subject ?p1 ?collection.
    filter regex(str(?p1), ".*relations-external.*", "i")
  }  {
    ?subject ?p ?o.
    filter (regex(str(?p), ".*dc.*", "i") && ?p != <dc:type>)
  }  {
    ?subject <dc:type> ?type_label .
    ?type a rdfs:Class .
    ?type rdfs:label ?type_label
  }
}

Regards,
Paul Gearon



More information about the Mulgara-dev mailing list