Re: Collection RDF using non-prefixed namespaces

25 views
Skip to first unread message

Nigel Banks

unread,
May 13, 2013, 2:56:43 PM5/13/13
to island...@googlegroups.com
Here is the code in question https://github.com/Islandora/islandora/blob/6.x/api/fedora_item.inc#L305-L354

Initially it looks like it should work, its using the appropriate function, but it seems that its expecting the first parameter to be qualified.

https://github.com/Islandora/islandora/blob/6.x/api/fedora_item.inc#L346

See:

So something like this might solve your problem
$contributions->add_relationship('fedora-model:hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);

Although you may need to explicitly include the namespace as well:

$relsext->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:fedora-model', FEDORA_MODEL_URI);

It seems as though the code has not been adding the prefix's automatically for some time now.

On Friday, May 10, 2013 3:18:23 PM UTC+2, Franck Falcoz wrote:
Hi,

     When creating a collection in the following way:

        $contributions = Fedora_Item::ingest_new_item($pid = '', $state = 'A', $label = 'Contributions', $owner = '');
        $contributions->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
        $contributions->add_relationship('isMemberOfCollection', $parent_pid);
        $contributions->add_relationship('contributionCollection', $parent_pid);

     Which looks to me pretty much like how it's done in the Islandora code, I end up with RDF which has namespaces at the tag level rather than using a prefix, e.g. <hasModel xmlns="info:fedora..."> instead of <fedora-model:hasModel>.

     The problem with that is that the result from get_rdf_relationships can contain hasModel or fedora-model:hasMode. I could check for both but I'd rather fix the RDF if possible.

     Anyone knows what I'm doing wrong? I'm using 6.x-13.1 and the problem appeared in that version... although that could also be because of some other change I did.

Cheers,
franck

Adam Vessey

unread,
May 13, 2013, 4:05:07 PM5/13/13
to island...@googlegroups.com
Depending on namespace prefixes (not) being there with XML is generally not a good idea (really, more of a problem with the original fedora_item code...). Using something like https://github.com/Islandora/islandora/blob/6.x/ObjectHelper.inc#L637-L674 to get the models would probably be a good idea, or using Tuque if possible... Similarly, getting the parents could be done with some more in-depth parsing... Some combination of https://github.com/Islandora/islandora/blob/6.x/ObjectHelper.inc#L637-L674 and https://github.com/Islandora/islandora/blob/6.x/ObjectHelper.inc#L961-L1013 possibly...  Though yeah... Tuque is awesome. :P

- Adam
--
You received this message because you are subscribed to the Google Groups "islandora-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to islandora-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Franck Falcoz

unread,
May 13, 2013, 7:48:28 PM5/13/13
to island...@googlegroups.com

So something like this might solve your problem
$contributions->add_relationship('fedora-model:hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);

     Thank you Nigel, that did the trick for me.

Although you may need to explicitly include the namespace as well:

$relsext->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:fedora-model', FEDORA_MODEL_URI); 

     I did not have to do that which is best since I was not creating the the relsext myself but only through calls to add_relationship. What I don't understand is that this used to work and I don't see the change in the Islandora code between version 12 and 13 that breaks it. Never mind though, it works now.

Thanks again!
franck

Franck Falcoz

unread,
May 13, 2013, 7:52:30 PM5/13/13
to island...@googlegroups.com
On Monday, May 13, 2013 10:05:07 PM UTC+2, Adam Vessey wrote:
Depending on namespace prefixes (not) being there with XML is generally not a good idea (really, more of a problem with the original fedora_item code...). Using something like https://github.com/Islandora/islandora/blob/6.x/ObjectHelper.inc#L637-L674 to get the models would probably be a good idea, or using Tuque if possible... Similarly, getting the parents could be done with some more in-depth parsing... Some combination of https://github.com/Islandora/islandora/blob/6.x/ObjectHelper.inc#L637-L674 and https://github.com/Islandora/islandora/blob/6.x/ObjectHelper.inc#L961-L1013 possibly...  Though yeah... Tuque is awesome. :P

     Thanks Adam! I am looking forward to using Tuque but for now Nigel's trick solved my problem.

Cheers,
franck

Reply all
Reply to author
Forward
0 new messages