1

Does anyone know of any method to canonicalize XML document in java 1.5, without using Canonicalizer class at Apache XML Security project? I can't upgrade java to a newer version and i can't use any external libraries.

By saying i can't use any external libraries i meant that i can use only JRE1.5 system library, can't import any additional .JAR files.

Simas.B
  • 724
  • 1
  • 13
  • 31

1 Answers1

1

As described in the DomConfiguration class, set the "canonical-form" configuration parameter to true, then call normalizeDocument:

void canonicalize(Document doc) {
    doc.getDomConfig().setParameter("canonical-form", true);
    doc.normalizeDocument();
}

The above methods are present in Java 1.5: https://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/Document.html

VGR
  • 40,506
  • 4
  • 48
  • 63