Reputation: 754
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.
Upvotes: 1
Views: 623
Reputation: 44385
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
Upvotes: 1