Sha256: c80bdaea4394798af33713096aab9ef7844d65a5338d9d49d582c75c8d0990b8

Contents?: true

Size: 537 Bytes

Versions: 2

Compression:

Stored size: 537 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.6.0 test/dtd-test.rb
libxml-ruby-0.6.0-x86-mswin32-60 test/dtd-test.rb