Class: Nokogiri::XML::DTD

Inherits:
Node
  • Object
show all
Defined in:
lib/nokogiri/xml/dtd.rb,
lib/nokogiri/ffi/xml/dtd.rb,
ext/nokogiri/xml_dtd.c

Constant Summary

Constants inherited from Node

Node::ATTRIBUTE_DECL, Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCB_DOCUMENT_NODE, Node::DOCUMENT_FRAG_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_TYPE_NODE, Node::DTD_NODE, Node::ELEMENT_DECL, Node::ELEMENT_NODE, Node::ENTITY_DECL, Node::ENTITY_NODE, Node::ENTITY_REF_NODE, Node::HTML_DOCUMENT_NODE, Node::NAMESPACE_DECL, Node::NOTATION_NODE, Node::PI_NODE, Node::TEXT_NODE, Node::XINCLUDE_END, Node::XINCLUDE_START

Instance Attribute Summary

Attributes inherited from Node

#cstruct

Instance Method Summary collapse

Methods inherited from Node

#<=>, #==, #>, #[], #[]=, #accept, #add_child, #add_namespace, #add_namespace_definition, #add_next_sibling, #add_previous_sibling, #after, #ancestors, #at, #at_css, #at_xpath, #attribute, #attribute_nodes, #attribute_with_ns, #before, #blank?, #cdata?, #child, #children, #clone, #comment?, #content, #content=, #create_external_subset, #create_internal_subset, #css, #css_path, #decorate!, #default_namespace=, #description, #document, #dup, #each, #element?, #element_children, #encode_special_chars, #external_subset, #first_element_child, #fragment, #fragment?, #has_attribute?, #html?, #initialize, #inner_html, #inner_html=, #inner_text, #internal_subset, #key?, #keys, #last_element_child, #line, #matches?, #name, #name=, #namespace, #namespace=, #namespace_definitions, #namespace_scopes, #namespaced_key?, #namespaces, new, #next, #next_element, #next_sibling, #node_name, #node_name=, node_properties, #node_type, #parent, #parent=, #parse, #path, #pointer_id, #previous, #previous_element, #previous_sibling, #read_only?, #remove, #remove_attribute, #replace, #search, #serialize, #set_attribute, #swap, #text, #text?, #to_html, #to_s, #to_xhtml, #to_xml, #traverse, #type, #unlink, #values, wrap, #write_html_to, #write_to, #write_xhtml_to, #write_xml_to, #xml?, #xpath

Methods included from PP::Node

#inspect, #pretty_print

Constructor Details

This class inherits a constructor from Nokogiri::XML::Node

Instance Method Details

#attributesObject

Get a hash of the attributes for this DTD.



80
81
82
# File 'ext/nokogiri/xml_dtd.c', line 80

def attributes
  internal_attributes :attributes
end

#elementsObject

Get a hash of the elements for this DTD.



102
103
104
# File 'ext/nokogiri/xml_dtd.c', line 102

def elements
  internal_attributes :elements
end

#entitiesObject

Get a hash of the elements for this DTD.



36
37
38
# File 'ext/nokogiri/xml_dtd.c', line 36

def entities
  internal_attributes :entities
end

#external_idObject

Get the External ID for this DTD



170
171
172
# File 'ext/nokogiri/xml_dtd.c', line 170

def external_id
  cstruct[:external_id]
end

#notationsObject

Get a hash of the notations for this DTD.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'ext/nokogiri/xml_dtd.c', line 58

def notations
  attr_ptr = cstruct[:notations]
  return nil if attr_ptr.null?

  ahash = {}
  LibXML.xmlHashScan(attr_ptr, nil) do |payload, data, name|
    notation_cstruct = LibXML::XmlNotation.new(payload)
    ahash[name] = Notation.new(notation_cstruct[:name], notation_cstruct[:PublicID],
                               notation_cstruct[:SystemID])
  end
  ahash
end

#system_idObject

Get the System ID for this DTD



154
155
156
# File 'ext/nokogiri/xml_dtd.c', line 154

def system_id
  cstruct[:system_id]
end

#validate(document) ⇒ Object

Validate document returning a list of errors



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'ext/nokogiri/xml_dtd.c', line 124

def validate document
  error_list = []
  ctxt = LibXML.xmlNewValidCtxt

  LibXML.xmlSetStructuredErrorFunc(nil, SyntaxError.error_array_pusher(error_list))
  LibXML.xmlValidateDtd ctxt, document.cstruct, cstruct

  LibXML.xmlSetStructuredErrorFunc nil, nil

  LibXML.xmlFreeValidCtxt ctxt

  error_list
end