How to create a checksum for an XML file in Java

I need to create a checksum for an XML file in Java. Primary requirements:

  • The order of the elements matters
  • The name-value attribute pair is important, but the order of the attributes is NOT:
  • Ignore all spaces and comments

Anyone can provide any hint or sample code?

Thanks Mark

+3
source share
3 answers

Method 1. Use XSLT to normalize the document.

Essentially, you should use XSLT to normalize XML documents so that equivalent documents go into the same document. Conversion:

  • Keeping items in order
  • Order attributes of each element (e.g. alphabetize based on attribute name)

.

:

2. DOM

  • DOM- DOM
  • DOM .
  • XML .

3. SAX StAX

DOM, SAX StAX XML //, , ///value/etc .

+2

API- Java Digital Signature API:

API Java XML

+6

W3C 'c14n'. + . . , libarry implemntation

+1

Source: https://habr.com/ru/post/1763633/


All Articles