Sha256: de4f88c8009ca5b9f8caba613a1dfcacf99c18cec1c1f2e0d41b0491aa69049c

Contents?: true

Size: 513 Bytes

Versions: 2

Compression:

Stored size: 513 Bytes

Contents

require "libxml"

xp = XML::Parser.new
xp.string = '<?xml version="1.0" encoding="utf-8"?>
<root><head a="ee" id="1">ass<buzz/></head><descr>really big ass</descr></root>'

doc = xp.parse

dtd = XML::Dtd.new('
<!ELEMENT root (head, descr)>
<!ELEMENT head (#PCDATA)>
<!ATTLIST head
  id NMTOKEN #REQUIRED
  a CDATA #IMPLIED
>
<!ELEMENT descr (#PCDATA)>
')

if doc.validate(dtd) { |message, error| puts "#{error ? 'error' : 'warning'} : #{message}" }
  puts "validation passed"
else
  puts "validation failed"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
libxml-ruby-0.5.3 test/dtd-test.rb
libxml-ruby-0.5.4 test/dtd-test.rb