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?, #encode_special_chars, #external_subset, #fragment, #has_attribute?, #html?, #initialize, #inner_html, #inner_html=, #inner_text, #internal_subset, #key?, #keys, #line, #matches?, #name, #name=, #namespace, #namespace=, #namespace_definitions, #namespaced_key?, #namespaces, new, #next, #next_sibling, #node_name, #node_name=, node_properties, #node_type, #parent, #parent=, #path, #pointer_id, #previous, #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.



76
77
78
# File 'ext/nokogiri/xml_dtd.c', line 76

def attributes
  internal_attributes :attributes
end

#elementsObject

Get a hash of the elements for this DTD.



96
97
98
# File 'ext/nokogiri/xml_dtd.c', line 96

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



160
161
162
# File 'ext/nokogiri/xml_dtd.c', line 160

def external_id
  cstruct[:external_id]
end

#notationsObject

Get a hash of the notations for this DTD.



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

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

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

#system_idObject

Get the System ID for this DTD



144
145
146
# File 'ext/nokogiri/xml_dtd.c', line 144

def system_id
  cstruct[:system_id]
end

#validate(document) ⇒ Object

Validate document returning a list of errors



116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'ext/nokogiri/xml_dtd.c', line 116

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