Class: Reddy::RdfXmlParser

Inherits:
Object
  • Object
show all
Defined in:
lib/reddy/rdfxmlparser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_str, uri = nil) ⇒ RdfXmlParser



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/reddy/rdfxmlparser.rb', line 11

def initialize(xml_str, uri = nil)
  @@syntax_base = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  @@rdf_type = @@syntax_base + "type"
  @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"]
  @uri = Addressable::URI.parse(uri).to_s unless uri.nil?
  @graph = Reddy::Graph.new
  @xml = LibXML::XML::Parser.string(xml_str).parse
  @id_mapping = Hash.new
  root = @xml.root
  if is_rdf_root?(root)
    root.each_element {|el|
      parse_descriptions(el)
    }
  else
    root.each_element {|n|
      if is_rdf_root?(n)
        n.each_element {|el|
          parse_descriptions(el)
        }
      end
    }
  end
end

Instance Attribute Details

#graphObject

Returns the value of attribute graph.



10
11
12
# File 'lib/reddy/rdfxmlparser.rb', line 10

def graph
  @graph
end

#xmlObject

Returns the value of attribute xml.



10
11
12
# File 'lib/reddy/rdfxmlparser.rb', line 10

def xml
  @xml
end