Class: Nokogiri::XML::DTD

### Home Classes Methods

### In Files

- lib/nokogiri/xml/dtd.rb
- ext/nokogiri/html_document.c

### Parent

Nokogiri::XML::Node

### Methods

- #attributes
- #each
- #elements
- #entities
- #external_id
- #html5_dtd?
- #html_dtd?
- #keys
- #notations
- #system_id
- #validate

### Files

- C_CODING_STYLE.rdoc
- Manifest.txt
- README.txt

### Class/Module Index

Quicksearch

- Nokogiri
- Nokogiri::CSS
- Nokogiri::CSS::Node
- Nokogiri::CSS::Parser
- Nokogiri::CSS::SyntaxError
- Nokogiri::CSS::Tokenizer
- Nokogiri::CSS::Tokenizer::ScanError
- Nokogiri::Decorators
- Nokogiri::Decorators::Slop
- Nokogiri::EncodingHandler
- Nokogiri::HTML
- Nokogiri::HTML::Builder
- Nokogiri::HTML::Document
- Nokogiri::HTML::Document::EncodingReader
- Nokogiri::HTML::Document::EncodingReader::JumpSAXHandler
- Nokogiri::HTML::DocumentFragment
- Nokogiri::HTML::ElementDescription
- Nokogiri::HTML::EntityDescription
- Nokogiri::HTML::EntityLookup
- Nokogiri::HTML::SAX
- Nokogiri::HTML::SAX::Parser
- Nokogiri::HTML::SAX::ParserContext
- Nokogiri::HTML::SAX::PushParser
- Nokogiri::SyntaxError
- Nokogiri::XML
- Nokogiri::XML::Attr
- Nokogiri::XML::AttributeDecl
- Nokogiri::XML::Builder
- Nokogiri::XML::CDATA
- Nokogiri::XML::CharacterData
- Nokogiri::XML::Comment
- Nokogiri::XML::DTD
- Nokogiri::XML::Document
- Nokogiri::XML::DocumentFragment
- Nokogiri::XML::Element
- Nokogiri::XML::ElementContent
- Nokogiri::XML::ElementDecl
- Nokogiri::XML::EntityDecl
- Nokogiri::XML::EntityReference
- Nokogiri::XML::Namespace
- Nokogiri::XML::Node
- Nokogiri::XML::Node::SaveOptions
- Nokogiri::XML::NodeSet
- Nokogiri::XML::Notation
- Nokogiri::XML::PP
- Nokogiri::XML::PP::CharacterData
- Nokogiri::XML::PP::Node
- Nokogiri::XML::ParseOptions
- Nokogiri::XML::ProcessingInstruction
- Nokogiri::XML::Reader
- Nokogiri::XML::RelaxNG
- Nokogiri::XML::SAX
- Nokogiri::XML::SAX::Document
- Nokogiri::XML::SAX::Parser
- Nokogiri::XML::SAX::Parser::Attribute
- Nokogiri::XML::SAX::ParserContext
- Nokogiri::XML::SAX::PushParser
- Nokogiri::XML::Schema
- Nokogiri::XML::Searchable
- Nokogiri::XML::SyntaxError
- Nokogiri::XML::Text
- Nokogiri::XML::XPath
- Nokogiri::XML::XPath::SyntaxError
- Nokogiri::XML::XPathContext
- Nokogiri::XSLT
- Nokogiri::XSLT::Stylesheet
- XSD
- XSD::XMLParser
- XSD::XMLParser::Nokogiri

No matching classes.

# Nokogiri::XML::DTD

### Public Instance Methods

attributes click to toggle source

Get a hash of the attributes for this DTD.

    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) click to toggle source

    # File lib/nokogiri/xml/dtd.rb, line 15
    def each &block
      attributes.each { |key, value|
        block.call([key, value])
      }
    end

elements click to toggle source

Get a hash of the elements for this DTD.

    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 click to toggle source

Get a hash of the elements for this DTD.

    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 click to toggle source

Get the External ID for this DTD

    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);
    }

html5_dtd?() click to toggle source

    # File lib/nokogiri/xml/dtd.rb, line 25
    def html5_dtd?
      html_dtd? &&
        external_id.nil? &&
        (system_id.nil? || system_id == 'about:legacy-compat')
    end

html_dtd?() click to toggle source

    # File lib/nokogiri/xml/dtd.rb, line 21
    def html_dtd?
      name.casecmp('html').zero?
    end

keys() click to toggle source

    # File lib/nokogiri/xml/dtd.rb, line 11
    def keys
      attributes.keys
    end

notations click to toggle source

Get a hash of the notations for this DTD.

    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 click to toggle source

Get the System ID for this DTD

    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) click to toggle source

Validate `document` returning a list of errors

    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;
    }

[Validate]

Generated with the Darkfish Rdoc Generator 2.