expanding functionality of semantic_node.rb

3 views
Skip to first unread message

LazyMonkey

unread,
Sep 22, 2010, 5:10:05 PM9/22/10
to ActiveFedora / Ruby + Fedora Commons
Hi Matt,

I was using AF (1.0.7) not too long ago, and was adding some RDF about
content models in the RELS-EXT datastream. I ran into a namespace
error that flummoxed me at first, until I realized the
outbound_relationships method was assigning "info:fedora/fedora-
system:def/relations-external#" as the xmlns of the triple, when I
needed "info:fedora/fedora-system:def/model#"

My solution was to change the xmlns variable as required, like so:

self.outbound_relationships.each do |predicate, targets_array|
targets_array.each do |target|
xmlns=String.new
case predicate
when :hasModel
xmlns="info:fedora/fedora-system:def/model#"
when :has_model
xmlns="info:fedora/fedora-system:def/model#"
else
xmlns="info:fedora/fedora-system:def/relations-external#"
end
# puts ". #{predicate} #{target} #{xmlns}"

xml.root.elements["rdf:Description"].add_element(self.class.predicate_lookup(predicate),
{"xmlns" => "#{xmlns}", "rdf:resource"=>target})
end
end
xml.to_s
end

If I was barking up the wrong tree, please let me know.

(I'm glad to see you've added :has_model => "hasModel", to the
PREDICATE_MAPPINGS table, btw. That was the other missing piece.)

Thanks again for your module.

Matthew Stephens
UVA Library

Matthew Zumwalt

unread,
Sep 22, 2010, 7:00:53 PM9/22/10
to active...@googlegroups.com
Hi Matt.

Good timing.  I'm about to make a round of changes in ActiveFedora and put out version 1.2.3 of the gem.  I've already applied your patch (with a test).  It will be there in the next version of the gem.  Here's the commit: http://github.com/mediashelf/active_fedora/commit/4ee1d43bfb8daaa99c5631f7c26a16e202251030


Matt Zumwalt
MediaShelf, LLC




--
You received this message because you are subscribed to the Google Groups "ActiveFedora / Ruby + Fedora Commons" group.
To post to this group, send email to active...@googlegroups.com.
To unsubscribe from this group, send email to active-fedor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/active-fedora?hl=en.


Reply all
Reply to author
Forward
0 new messages