Class: Rena::RdfXmlParser
- Inherits:
-
Object
- Object
- Rena::RdfXmlParser
- Defined in:
- lib/rena/rdfxmlparser.rb
Constant Summary collapse
- SYNTAX_BASE =
"http://www.w3.org/1999/02/22-rdf-syntax-ns"- RDF_TYPE =
SYNTAX_BASE + "#type"
- RDF_DESCRIPTION =
SYNTAX_BASE + "#Description"
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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rena/rdfxmlparser.rb', line 16 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.
15 16 17 |
# File 'lib/rena/rdfxmlparser.rb', line 15 def graph @graph end |
#xml ⇒ Object
Returns the value of attribute xml.
15 16 17 |
# File 'lib/rena/rdfxmlparser.rb', line 15 def xml @xml end |
Instance Method Details
#is_rdf? ⇒ Boolean
36 37 38 39 40 41 42 43 |
# File 'lib/rena/rdfxmlparser.rb', line 36 def is_rdf? @xml.each_element do |e| if e.namespaces.has_value? "http://www.w3.org/1999/02/22-rdf-syntax-ns#" return true end end return false end |