File: digesttest.rb

package info (click to toggle)
libxml-parser-ruby 0.5.16-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 596 kB
  • ctags: 702
  • sloc: ruby: 4,474; ansic: 1,254; xml: 542; makefile: 53
file content (26 lines) | stat: -rwxr-xr-x 613 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /usr/local/bin/ruby

## DOMHASH test
## 1999 by yoshidam
##
## Namespace support required
##
## Apr 20, 1999 Change for draft-hiroshi-dom-hash-01.txt
##

require 'xmltreebuilder'
require 'xmldigest'

p = XML::DOM::Builder.new(0, nil, ":") ## nssep must be ':'
if p.respond_to?(:setParamEntityParsing)
  p.setParamEntityParsing(XML::Parser::PARAM_ENTITY_PARSING_UNLESS_STANDALONE)
end
begin
  tree = p.parse($<.read, true)
rescue XML::ParserError
  print "#{$<.filename}:#{p.line}: #{$!}\n"
  exit
end
tree.documentElement.normalize
tree.documentElement.getDigest.each_byte { |c|; print "%02X" % c }
print "\n"