Class: RdfXmlParser
- Inherits:
-
Object
- Object
- RdfXmlParser
- Defined in:
- lib/rena/rdfxmlparser.rb
Instance Attribute Summary collapse
-
#graph ⇒ Object
Returns the value of attribute graph.
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(xml_str, uri = nil) ⇒ RdfXmlParser
constructor
A new instance of RdfXmlParser.
- #is_rdf? ⇒ Boolean
Constructor Details
#initialize(xml_str, uri = nil) ⇒ RdfXmlParser
Returns a new instance of RdfXmlParser.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rena/rdfxmlparser.rb', line 10 def initialize (xml_str, uri = nil) @excl = ["http://www.w3.org/1999/02/22-rdf-syntax-ns#resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#nodeID", "http://www.w3.org/1999/02/22-rdf-syntax-ns#about", "http://www.w3.org/1999/02/22-rdf-syntax-ns#ID"] if uri != nil @uri = Addressable::URI.parse(uri) end @xml = REXML::Document.new(xml_str) # self.iterator @xml.root.children if self.is_rdf? @graph = Graph.new @xml.root.each_element { |e| self.parse_element e } # puts @graph.size end end |
Instance Attribute Details
#graph ⇒ Object
Returns the value of attribute graph.
9 10 11 |
# File 'lib/rena/rdfxmlparser.rb', line 9 def graph @graph end |
#xml ⇒ Object
Returns the value of attribute xml.
9 10 11 |
# File 'lib/rena/rdfxmlparser.rb', line 9 def xml @xml end |
Instance Method Details
#is_rdf? ⇒ Boolean
26 27 28 29 30 31 32 33 34 |
# File 'lib/rena/rdfxmlparser.rb', line 26 def is_rdf? trigger = false @xml.each_element do |e| if e.namespaces.has_value? "http://www.w3.org/1999/02/22-rdf-syntax-ns#" trigger = true end end return trigger end |