Sha256: 91f89556a16fa606dd1520e3c1e0ec8c7f8334adbe1185239f4867bc985747ff
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
module TaliaCore module ActiveSourceParts module Xml # Class for creating xml-rdf Data from a source. See the parent class, TaliaUtil::Xml::RdfBuilder, for # more information. class RdfBuilder < TaliaUtil::Xml::RdfBuilder # Builds the RDF for a source and returns the result as a string def self.build_source(source) make_xml_string { |build| build.write_source(source) } end # Builds the RDF for a source. This will include both the "direct" predicates as well as the # "inverse" (incoming predicates of a source) def write_source(source) # The source is written as subject, with all the triples nested inside it. @builder.rdf :Description, 'rdf:about' => source.uri.to_s do # Element describing this resource # loop through the predicates source.direct_predicates.each do |predicate| write_predicate(predicate, source[predicate]) end end # Each of the inverse properties creates another subject entry, that just contains the one # triple relating it to the current source. (In this case, the subject and predicate entries # aren't merged any further) source.inverse_predicates.each do |predicate| source.inverse[predicate].each do |inverse_subject| @builder.rdf :Description, 'rdf:about' => inverse_subject do write_predicate(predicate, [source]) end end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
talia_core-0.7.0 | lib/talia_core/active_source_parts/xml/rdf_builder.rb |