Sha256: b09f84cdc0d3e37818d8458fe11a529df4d0eae5a90336ccf59ae53ad3fafd67

Contents?: true

Size: 552 Bytes

Versions: 35

Compression:

Stored size: 552 Bytes

Contents

#!/usr/bin/env ruby1.9

#
# A small script to extract entities from the ONIX DTD
#
# USAGE: ./extract <dir>
#
# Where dir is a directory containing an ONIX 2.1r3 DTD.
#

unless File.directory?(ARGV.first)
  $stderr.puts "directory doesn't exist"
  exit(1)
end

Dir.entries(ARGV.first).each do |f|
  next unless f[-4,4] == ".ent"

  content = File.binread(ARGV.first + "/" + f)
  content.scan(/ENTITY [a-zA-Z0-9]+.*"\&#x.+;/).each do |str|
    m, name, numeric = *str.match(/ENTITY ([a-zA-Z0-9]+).*"\&([^;]+);/)
    puts "#{name}:#{numeric}"
  end

end

Version data entries

35 entries across 35 versions & 4 rubygems

Version Path
cacofonix-0.10.3 support/extract.rb
cacofonix-0.10.2 support/extract.rb
cacofonix-0.10.1 support/extract.rb
cacofonix-0.10.0 support/extract.rb
onix2-1.0.0 support/extract.rb
onix-0.9.5 support/extract.rb
onix-0.9.4 support/extract.rb
milkfarm-onix-0.8.13 support/extract.rb
milkfarm-onix-0.8.12 support/extract.rb
onix-0.9.3 support/extract.rb
onix-0.9.2 support/extract.rb
onix-0.9.1 support/extract.rb
milkfarm-onix-0.8.11 support/extract.rb
milkfarm-onix-0.8.10 support/extract.rb
onix-0.9.0 support/extract.rb
milkfarm-onix-0.8.9 support/extract.rb
milkfarm-onix-0.8.8 support/extract.rb
milkfarm-onix-0.8.7 support/extract.rb
onix-0.8.5 support/extract.rb
onix-0.8.4 support/extract.rb