Class: REXML::DocType

Inherits:
Object
  • Object
show all
Defined in:
lib/test/unit/xml/doctype_mixin.rb

Overview

The REXML::DocType mix-in adds methods that are useful for Doctype declarations, but not present in the standard REXML::DocType class

Instance Method Summary collapse

Instance Method Details

#notation(name) ⇒ Object

Retrieves a named notation. Only notations declared in the internal DTD subset can be retrieved.



40
41
42
43
44
# File 'lib/test/unit/xml/doctype_mixin.rb', line 40

def notation(name)
  notations.find { |notation_decl|
    notation_decl.name == name
  }
end

#notationsObject

This method returns a list of notations that have been declared in the internal DTD subset. Notations in the external DTD subset are not listed.



34
35
36
# File 'lib/test/unit/xml/doctype_mixin.rb', line 34

def notations
  children().select {|node| node.kind_of?(REXML::NotationDecl)}
end

#publicObject

This method retrieves the public identifier identifying the document’s DTD.



13
14
15
16
17
18
19
20
# File 'lib/test/unit/xml/doctype_mixin.rb', line 13

def public
  case @external_id
  when "SYSTEM"
    nil
  when "PUBLIC"
    strip_quotes(@long_name)
  end
end

#systemObject

This method retrieves the system identifier identifying the document’s DTD



23
24
25
26
27
28
29
30
# File 'lib/test/unit/xml/doctype_mixin.rb', line 23

def system
  case @external_id
  when "SYSTEM"
    strip_quotes(@long_name)
  when "PUBLIC"
    @uri.kind_of?(String) ? strip_quotes(@uri) : nil
  end
end