Hi Kim
I don't believe the addRelationship REST API method has any mechanism for
specifying/declaring namespace prefixes, so I think you will have to use the
full URI form, as you seem to have discovered.
In terms of the dissemination of either the relationships or the RELS-EXT
datastream directly, the output seems to be semantically identical in both
cases (equivalent in both XML and RDF terms) - does it cause you any
particular issue whether there are namespace prefixes declared or whether a
default namespace is used for a particular element?
Regards
Steve
-----Original Message-----
From: Kim Shepherd [mailto:kim.sheph...@gmail.com]
Sent: 04 October 2010 04:00
To: fedora-commons-users@lists.sourceforge.net
Subject: Re: [fcrepo-user] REST/API-M getRelationships,addRelationships and
RELS-EXT (correction)
Correction to my very last example -- there should be no colon between the
encoded namespace and the isPartOf predicate or after the # in the namespace
shown in the resulting RDF
(that'll teach me to copy and paste parts of my examples instead of the full
strings!)
Fixed example:
[...]
http://www.example.com:8080/fedora/objects/ampm:801/relationships/new?subjec
t=info:fedora/ampm:801
<http://www.example.com:8080/fedora/objects/ampm:801/relationships/new?subje
ct=info:fedora/ampm:801&predicate=info%3Afedora%2Ffedora-system%3Adef%2Frela
tions-external%23:isPartOf&object=info:fedora/ampm:100>
&predicate=info%3Afedora%2Ffedora-system%3Adef%2Frelations-external%23isPart
Of&object=info:fedora/ampm:100
...which seems to result in a working RELS-EXT, although the prefixes are
still replaced with explicit namespace attributes:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="info:fedora/ampm:801">
<isMemberOf xmlns="info:fedora/fedora-system:def/relations-external#"
rdf:resource="info:fedora/ampm:Archive"></isMemberOf>
<hasModel xmlns="info:fedora/fedora-system:def/model#"
rdf:resource="info:fedora/ampm:Media"></hasModel>
<isPartOf xmlns="info:fedora/fedora-system:def/relations-external#"
rdf:resource="info:fedora/ampm:100"></isPartOf>
</rdf:Description>
</rdf:RDF>
[...]
Cheers,
Kim
---------- Forwarded message ----------
From: Kim Shepherd <kim.sheph...@gmail.com>
Date: 4 October 2010 15:52
Subject: REST/API-M getRelationships, addRelationships and RELS-EXT
To: fedora-commons-users@lists.sourceforge.net
Hi all,
I'm mostly using the REST API to manage a Fedora 3.4 instance, and I'm
getting a bit confused when managing RELS-EXT -- namely, the formatting
difference I see when retrieving and storing relationships.
Example:
http://www.example.com:8080/fedora/objects/ampm:801/datastreams/RELS-EXT/con
tent
Gives the following output:
<rdf:RDF xmlns:fedora-model="info:fedora/fedora-system:def/model#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rel="info:fedora/fedora-system:def/relations-external#"
xmlns:myns="http://www.nsdl.org/ontologies/relationships#">
<rdf:Description
rdf:about="info:fedora/ampm:801">
<rel:isMemberOf
rdf:resource="info:fedora/ampm:Archive"></rel:isMemberOf>
<fedora-model:hasModel
rdf:resource="info:fedora/ampm:Media"></fedora-model:hasModel>
</rdf:Description>
</rdf:RDF>
...which is what I expect, as that's how the objects were originally
ingested. Note the namespace specified in the opening rdf:RDF tag and the
use of prefixes throughout.
And this method:
http://www.example.com:8080/fedora/objects/ampm:801/relationships (using
GET)
Gives the following output:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="info:fedora/ampm:801">
<hasModel xmlns="info:fedora/fedora-system:def/model#"
rdf:resource="info:fedora/ampm:Media"/>
<hasModel xmlns="info:fedora/fedora-system:def/model#"
rdf:resource="info:fedora/fedora-system:FedoraObject-3.0"/>
<isMemberOf xmlns="info:fedora/fedora-system:def/relations-external#"
rdf:resource="info:fedora/ampm:Archive"/>
</rdf:Description>
</rdf:RDF>
If this is just how the /relationship/ method prefers to disseminate the
RDF, that's fine by me, but where I'm *really* running into trouble is when
I try to add a new relationship.
If I use a POST like:
http://www.example.com:8080/fedora/objects/ampm:801/relationships/new?subjec
t=info:fedora/ampm:801
<http://www.example.com:8080/fedora/objects/ampm:801/relationships/new?subje
ct=info:fedora/ampm:801&predicate=rel:isPartOf&object=info:fedora/ampm:100>
&predicate=rel:isPartOf&object=info:fedora/ampm:100
I get back an HTTP 200 OK response, but the RELS-EXT datastream now looks
like this:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="info:fedora/ampm:801">
<isMemberOf xmlns="info:fedora/fedora-system:def/relations-external#"
rdf:resource="info:fedora/ampm:Archive"></isMemberOf>
<hasModel xmlns="info:fedora/fedora-system:def/model#"
rdf:resource="info:fedora/ampm:Media"></hasModel>
<isPartOf xmlns="rel:" rdf:resource="info:fedora/ampm:100"></isPartOf>
</rdf:Description>
</rdf:RDF>
The removal of prefixes and explicit inclusion of namespaces to each element
is one thing, but it's also gone ahead and treated rel: as a namespace
instead of a namespace prefix (I think?!), which breaks stuff.
Never being one to give up, I encoded the full namespace URI and tried
passing that as a "prefix" when sending my API call:
http://www.example.com:8080/fedora/objects/ampm:801/relationships/new?subjec
t=info:fedora/ampm:801
<http://www.example.com:8080/fedora/objects/ampm:801/relationships/new?subje
ct=info:fedora/ampm:801&predicate=info%3Afedora%2Ffedora-system%3Adef%2Frela
tions-external%23:isPartOf&object=info:fedora/ampm:100>
&predicate=info%3Afedora%2Ffedora-system%3Adef%2Frelations-external%23:isPar
tOf&object=info:fedora/ampm:100
...which seems to result in a working RELS-EXT, although the prefixes are
still replaced with explicit namespace attributes:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="info:fedora/ampm:801">
<isMemberOf xmlns="info:fedora/fedora-system:def/relations-external#"
rdf:resource="info:fedora/ampm:Archive"></isMemberOf>
<hasModel xmlns="info:fedora/fedora-system:def/model#"
rdf:resource="info:fedora/ampm:Media"></hasModel>
<isPartOf xmlns="info:fedora/fedora-system:def/relations-external#:"
rdf:resource="info:fedora/ampm:100"></isPartOf>
</rdf:Description>
</rdf:RDF>
Now, I don't particularly mind how this datastream is formatted, as long as
I can be sure that the Resource Index is happy with it like this, and that I
know which "prefix" to consistently use when adding new relationships. Will
I run into bother if I don't use prefixes?
Given that the "GET" relationships method seems to crosswalk between the raw
RELS-EXT and the prefix-less RDF, was the "POST" method intended to do a
similar job, so that the raw RDF was able to keep prefixes?
Thanks in advance for any helpful tips! If I'm doing something silly with my
RELS-EXT please point it out, because I'm fairly new to the Fedora Resource
Index.
Cheers,
Kim
Kim Shepherd
Te Tumu Herenga
University of Auckland
------------------------------------------------------------------------------
Virtualization is moving to the mainstream and overtaking non-virtualized
environment for deploying applications. Does it make network security
easier or more difficult to achieve? Read this whitepaper to separate the
two and get a better understanding.
http://p.sf.net/sfu/hp-phase2-d2d
_______________________________________________
Fedora-commons-users mailing list
Fedora-commons-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fedora-commons-users