class HTree::DocType
Attributes
public_identifier[R]
root_element_name[R]
system_identifier[R]
Public Class Methods
new(root_element_name, public_identifier=nil, system_identifier=nil)
click to toggle source
# File htree/leaf.rb, line 25 def initialize(root_element_name, public_identifier=nil, system_identifier=nil) init_raw_string if public_identifier && /\A[ \x0d\x0aa-zA-Z0-9\-'()+,.\/:=?;!*\#@$_%]*\z/ !~ public_identifier raise HTree::Error, "invalid public identifier in document type declaration: #{public_identifier.inspect}" end if system_identifier && /"/ =~ system_identifier && /'/ =~ system_identifier raise HTree::Error, "invalid system identifier in document type declaration: #{system_identifier.inspect}" end @root_element_name = root_element_name @public_identifier = public_identifier @system_identifier = system_identifier end
parse(raw_string, is_xml, is_html)
click to toggle source
# File htree/parse.rb, line 372 def DocType.parse(raw_string, is_xml, is_html) unless /\A#{Pat::DocType_C}\z/o =~ raw_string raise HTree::Error, "cannot recognize as XML declaration: #{raw_string.inspect}" end root_element_name = $1 public_identifier = $2 || $3 system_identifier = $4 || $5 root_element_name = root_element_name.downcase if !is_xml && is_html result = DocType.new(root_element_name, public_identifier, system_identifier) result.raw_string = raw_string result end