Class: RDFObject::XMLTestDocument
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- RDFObject::XMLTestDocument
- Defined in:
- lib/rdf_objects/parsers.rb
Instance Method Summary collapse
- #end_element(name) ⇒ Object
-
#initialize ⇒ XMLTestDocument
constructor
A new instance of XMLTestDocument.
- #is_doc? ⇒ Boolean
- #is_html? ⇒ Boolean
- #is_rdf? ⇒ Boolean
- #start_element(name, attrs = []) ⇒ Object
Constructor Details
#initialize ⇒ XMLTestDocument
Returns a new instance of XMLTestDocument.
249 250 251 252 253 |
# File 'lib/rdf_objects/parsers.rb', line 249 def initialize @xml_start = false @xml_end = false @namespaces = [] end |
Instance Method Details
#end_element(name) ⇒ Object
265 266 267 268 269 |
# File 'lib/rdf_objects/parsers.rb', line 265 def end_element(name) if @xml_start @xml_end = true if name = @xml_start end end |
#is_doc? ⇒ Boolean
271 272 273 274 |
# File 'lib/rdf_objects/parsers.rb', line 271 def is_doc? return true if @xml_start && @xml_end return false end |
#is_html? ⇒ Boolean
281 282 283 284 285 |
# File 'lib/rdf_objects/parsers.rb', line 281 def is_html? return true if @namespaces.index("http://www.w3.org/1999/xhtml") return true if @xml_start =~ /html/i return false end |
#is_rdf? ⇒ Boolean
276 277 278 279 |
# File 'lib/rdf_objects/parsers.rb', line 276 def is_rdf? return true if @namespaces.index("http://www.w3.org/1999/02/22-rdf-syntax-ns#") return false end |
#start_element(name, attrs = []) ⇒ Object
255 256 257 258 259 260 261 262 263 |
# File 'lib/rdf_objects/parsers.rb', line 255 def start_element(name, attrs=[]) @xml_start = name attrs.each do | attrib | next unless attrib.is_a?(Array) if attrib.first =~ /^xmlns(:|\b)/ @namespaces << attrib.last end end end |