Sha256: 0aa63d6b645fdbac72815e8b2a7ee0a753ca1f627b28b8a511658b4674e6c17a

Contents?: true

Size: 1.49 KB

Versions: 21

Compression:

Stored size: 1.49 KB

Contents

# :stopdoc:
module Nokogiri
  module XML
    class DTD < Node
      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

      def system_id
        cstruct[:system_id]
      end

      def external_id
        cstruct[:external_id]
      end

      def elements
        internal_attributes :elements
      end

      def entities
        internal_attributes :entities
      end

      def attributes
        internal_attributes :attributes
      end

      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

      private

      def internal_attributes attr_name
        attr_ptr = cstruct[attr_name.to_sym]
        ahash = {}
        return ahash if attr_ptr.null?

        LibXML.xmlHashScan(attr_ptr, nil) do |payload, data, name|
          ahash[name] = Node.wrap(payload)
        end
        ahash
      end
    end
  end
end
# :startdoc:

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
domo-0.0.4 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.4.4/lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.7-java lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.7-x86-mingw32 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.7-x86-mswin32-60 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.7 lib/nokogiri/ffi/xml/dtd.rb
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/nokogiri-1.4.6/lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.6 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.6-java lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.6-x86-mingw32 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.6-x86-mswin32-60 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.5-java lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.5 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.5-x86-mswin32-60 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.5-x86-mingw32 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.4.2-java lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.4.1-x86-mswin32 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.4.1-x86-mingw32 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.4-x86-mswin32 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.4-x86-mingw32 lib/nokogiri/ffi/xml/dtd.rb
nokogiri-1.4.4-java lib/nokogiri/ffi/xml/dtd.rb