64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/xml/dom/digest.rb', line 64
def getDigest(force = false)
return @digest if (!force && @digest)
attr = attributes
children = childNodes
attr_digests = ""
children_digests = ""
if attr
attr_array = attr.sort {|a, b|
DOM.tou16(a.nodeName) <=> DOM.tou16(b.nodeName)}
attr_array.each {|a|
attr_digests << a.getDigest(force)
}
end
children_num = 0
children.each {|c|
next if c.nodeType ==
children_num += 1
children_digests << c.getDigest(force)
}
@digest = MD5.new([ELEMENT_NODE].pack("N") +
DOM.tou16(nodeName) +
"\0\0" +
[attr.length].pack("N") +
attr_digests +
[children_num].pack("N") +
children_digests).digest
end
|