Class: Nokogiri::XML::DTD
- Defined in:
- lib/nokogiri/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 Method Summary collapse
-
#attributes ⇒ Object
Get a hash of the attributes for this DTD.
- #each(&block) ⇒ Object
-
#elements ⇒ Object
Get a hash of the elements for this DTD.
-
#entities ⇒ Object
Get a hash of the elements for this DTD.
-
#external_id ⇒ Object
Get the External ID for this DTD.
- #keys ⇒ Object
-
#notations ⇒ Object
Get a hash of the notations for this DTD.
-
#system_id ⇒ Object
Get the System ID for this DTD.
-
#validate(document) ⇒ Object
Validate
document
returning a list of errors.
Methods inherited from Node
#<<, #<=>, #==, #>, #[], #[]=, #accept, #add_child, #add_namespace_definition, #add_next_sibling, #add_previous_sibling, #after, #ancestors, #at, #at_css, #at_xpath, #attribute, #attribute_nodes, #attribute_with_ns, #before, #blank?, #canonicalize, #cdata?, #child, #children, #children=, #comment?, #content, #content=, #create_external_subset, #create_internal_subset, #css, #css_path, #decorate!, #default_namespace=, #description, #do_xinclude, #document, #dup, #element?, #element_children, #encode_special_chars, #external_subset, #first_element_child, #fragment, #fragment?, #html?, #initialize, #inner_html, #inner_html=, #internal_subset, #key?, #last_element_child, #line, #matches?, #namespace, #namespace=, #namespace_definitions, #namespace_scopes, #namespaced_key?, #namespaces, new, #next_element, #next_sibling, #node_name, #node_name=, #node_type, #parent, #parent=, #parse, #path, #pointer_id, #previous_element, #previous_sibling, #read_only?, #remove_attribute, #replace, #search, #serialize, #swap, #text?, #to_html, #to_s, #to_xhtml, #to_xml, #traverse, #unlink, #values, #write_html_to, #write_to, #write_xhtml_to, #write_xml_to, #xml?, #xpath
Methods included from PP::Node
Constructor Details
This class inherits a constructor from Nokogiri::XML::Node
Instance Method Details
#attributes ⇒ Object
Get a hash of the attributes for this DTD.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'ext/nokogiri/xml_dtd.c', line 80
static VALUE attributes(VALUE self)
{
xmlDtdPtr dtd;
VALUE hash;
Data_Get_Struct(self, xmlDtd, dtd);
hash = rb_hash_new();
if(!dtd->attributes) return hash;
xmlHashScan((xmlHashTablePtr)dtd->attributes, element_copier, (void *)hash);
return hash;
}
|
#each(&block) ⇒ Object
15 16 17 18 19 |
# File 'lib/nokogiri/xml/dtd.rb', line 15 def each &block attributes.each { |key, value| block.call([key, value]) } end |
#elements ⇒ Object
Get a hash of the elements for this DTD.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'ext/nokogiri/xml_dtd.c', line 102
static VALUE elements(VALUE self)
{
xmlDtdPtr dtd;
VALUE hash;
Data_Get_Struct(self, xmlDtd, dtd);
if(!dtd->elements) return Qnil;
hash = rb_hash_new();
xmlHashScan((xmlHashTablePtr)dtd->elements, element_copier, (void *)hash);
return hash;
}
|
#entities ⇒ Object
Get a hash of the elements for this DTD.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'ext/nokogiri/xml_dtd.c', line 36
static VALUE entities(VALUE self)
{
xmlDtdPtr dtd;
VALUE hash;
Data_Get_Struct(self, xmlDtd, dtd);
if(!dtd->entities) return Qnil;
hash = rb_hash_new();
xmlHashScan((xmlHashTablePtr)dtd->entities, element_copier, (void *)hash);
return hash;
}
|
#external_id ⇒ Object
Get the External ID for this DTD
170 171 172 173 174 175 176 177 178 |
# File 'ext/nokogiri/xml_dtd.c', line 170
static VALUE external_id(VALUE self)
{
xmlDtdPtr dtd;
Data_Get_Struct(self, xmlDtd, dtd);
if(!dtd->ExternalID) return Qnil;
return NOKOGIRI_STR_NEW2(dtd->ExternalID);
}
|
#keys ⇒ Object
11 12 13 |
# File 'lib/nokogiri/xml/dtd.rb', line 11 def keys attributes.keys end |
#notations ⇒ Object
Get a hash of the notations for this DTD.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'ext/nokogiri/xml_dtd.c', line 58
static VALUE notations(VALUE self)
{
xmlDtdPtr dtd;
VALUE hash;
Data_Get_Struct(self, xmlDtd, dtd);
if(!dtd->notations) return Qnil;
hash = rb_hash_new();
xmlHashScan((xmlHashTablePtr)dtd->notations, notation_copier, (void *)hash);
return hash;
}
|
#system_id ⇒ Object
Get the System ID for this DTD
154 155 156 157 158 159 160 161 162 |
# File 'ext/nokogiri/xml_dtd.c', line 154
static VALUE system_id(VALUE self)
{
xmlDtdPtr dtd;
Data_Get_Struct(self, xmlDtd, dtd);
if(!dtd->SystemID) return Qnil;
return NOKOGIRI_STR_NEW2(dtd->SystemID);
}
|
#validate(document) ⇒ Object
Validate document
returning a list of errors
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'ext/nokogiri/xml_dtd.c', line 124
static VALUE validate(VALUE self, VALUE document)
{
xmlDocPtr doc;
xmlDtdPtr dtd;
xmlValidCtxtPtr ctxt;
VALUE error_list;
Data_Get_Struct(self, xmlDtd, dtd);
Data_Get_Struct(document, xmlDoc, doc);
error_list = rb_ary_new();
ctxt = xmlNewValidCtxt();
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
xmlValidateDtd(ctxt, doc, dtd);
xmlSetStructuredErrorFunc(NULL, NULL);
xmlFreeValidCtxt(ctxt);
return error_list;
}
|