Skip to content
Browse files

updated RdfXmlParser to match new libxml version

  • Loading branch information...
1 parent e8334fb commit d3fb093b6c34cc1b2d8bbb2f6ac1869e863171c5 Tom Morris committed Feb 2, 2009
Showing with 12 additions and 12 deletions.
  1. +12 −12 lib/reddy/rdfxmlparser.rb
View
24 lib/reddy/rdfxmlparser.rb
@@ -39,7 +39,7 @@ def initialize(xml_str, uri = nil)
def is_rdf_root? (node)
#TODO: clean this method up to make it more like Ruby and less like retarded Java
if node.name == "RDF"
- if !node.namespace.nil? && node.namespace_node.href == @@syntax_base
+ if !node.namespaces.nil? && node.namespaces.namespace.href == @@syntax_base
return true
end
else
@@ -53,7 +53,7 @@ def parse_descriptions(el, subject=nil)
# class and container classes
# following commented out - if we decide that special Container handling is required, we can do it here.
# until then, the procedure I'm using is simple: checking for rdf:li elements when handling children
- # case [el.namespace_node.href, el.name]
+ # case [el.namespaces.namespace.href, el.name]
# when [@@syntax_base, "Bag"]
# when [@@syntax_base, "Seq"]
# when [@@syntax_base, "Alt"]
@@ -62,20 +62,20 @@ def parse_descriptions(el, subject=nil)
# #when [@@syntax_base, "Container"] - from my reading of RDFS 1.0 (2004)
# #§5.1.1, we should not expect to find Containers inside public documents.
# else
- # @graph.add_triple(subject, @@rdf_type, url_helper(el.name, el.namespace_node.href, el.base))
+ # @graph.add_triple(subject, @@rdf_type, url_helper(el.name, el.namespaces.namespace.href, el.base_uri))
# end
# If we ever decide to do special handling for OWL, here's where we can shove it. If. --tom
- unless el.name == "Description" && el.namespace_node.href == @@syntax_base
- @graph.add_triple(subject, @@rdf_type, url_helper(el.name, el.namespace_node.href, el.base))
+ unless el.name == "Description" && el.namespaces.namespace.href == @@syntax_base
+ @graph.add_triple(subject, @@rdf_type, url_helper(el.name, el.namespaces.namespace.href, el.base_uri))
end
# read each attribute that's not in @@syntax_base
el.attributes.each { |att|
- @graph.add_triple(subject, url_helper(att.name, att.ns.href, el.base), att.value) unless att.ns.href == @@syntax_base
+ @graph.add_triple(subject, url_helper(att.name, att.ns.href, el.base_uri), att.value) unless att.ns.href == @@syntax_base
}
li_counter = 0 # this will increase for each li we iterate through
el.each_element {|child|
- predicate = url_helper(child.name, child.namespace_node.href, child.base)
+ predicate = url_helper(child.name, child.namespaces.namespace.href, child.base_uri)
if predicate.to_s == @@syntax_base + "li"
li_counter += 1
predicate = Addressable::URI.parse(predicate.to_s)
@@ -86,7 +86,7 @@ def parse_descriptions(el, subject=nil)
if el.attributes.get_attribute_ns(@@syntax_base, "nodeID")
@graph.add_triple(subject, predicate, forge_bnode_from_string(child.attributes.get_attribute_ns(@@syntax_base, "nodeID").value))
elsif child.attributes.get_attribute_ns(@@syntax_base, "resource")
- @graph.add_triple(subject, predicate, URIRef.new(base_helper(child.attributes.get_attribute_ns(@@syntax_base, "resource").value, child.base).to_s))
+ @graph.add_triple(subject, predicate, URIRef.new(base_helper(child.attributes.get_attribute_ns(@@syntax_base, "resource").value, child.base_uri).to_s))
end
child.each {|contents|
if contents.text? and contents.content.strip.length != 0
@@ -124,7 +124,7 @@ def parse_descriptions(el, subject=nil)
# reification
if child.attributes.get_attribute_ns(@@syntax_base, "ID")
if id_check?(child.attributes.get_attribute_ns(@@syntax_base, "ID").value)
- rsubject = url_helper("#" + child.attributes.get_attribute_ns(@@syntax_base, "ID").value, child.base)
+ rsubject = url_helper("#" + child.attributes.get_attribute_ns(@@syntax_base, "ID").value, child.base_uri)
@graph.add_triple(rsubject, URIRef.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), URIRef.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"))
@graph.add_triple(rsubject, URIRef.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"), subject)
@graph.add_triple(rsubject, URIRef.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"), predicate)
@@ -156,11 +156,11 @@ def parse_subject(el)
if el.attributes.get_attribute_ns(@@syntax_base, "about")
#debugger if el.attributes.get_attribute_ns(@@syntax_base, "about").value =~ /artist$/
- return URIRef.new(base_helper(el.attributes.get_attribute_ns(@@syntax_base, "about").value, el.base).to_s)
+ return URIRef.new(base_helper(el.attributes.get_attribute_ns(@@syntax_base, "about").value, el.base_uri).to_s)
elsif el.attributes.get_attribute_ns(@@syntax_base, "ID")
id = el.attributes.get_attribute_ns(@@syntax_base, "ID")
if id_check?(id.value)
- return url_helper("#" + id.value, "", el.base)
+ return url_helper("#" + id.value, "", el.base_uri)
else
raise
end
@@ -183,7 +183,7 @@ def parse_subject(el)
end
if uri == @@syntax_base + "#resource" || uri == @@syntax_base + "#about" #specified resource
- subject = URIRef.new(base_helper(value, el.base))
+ subject = URIRef.new(base_helper(value, el.base_uri))
end
if uri.to_s == @@syntax_base + "#nodeID" #BNode with ID

0 comments on commit d3fb093

Please sign in to comment.
Something went wrong with that request. Please try again.