Android XML Canonicalization

angel

New Member
I'm trying to canonicalize some xml I receive from a server on an android device. However, Android does not seem to like \[code\]org.apache.xml.security.c14n.Canonicalizer.canonicalize(String inputText)\[/code\]. This is because Android's DOM library does not like \[code\]DocumentBuilder.setValidating()\[/code\] (used by Canonicalizer), which automatically throws an exception.I tried copying the code directly from Canonicalizer without that troublesome line:\[code\]DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();InputSource in = new InputSource(new ByteArrayInputStream(inputBytes));DocumentBuilder db = dbf.newDocumentBuilder();Document doc = db.parse(in);byte result[] = Canonicalizer.getInstance(canonicalizationMethod).canonicalizeSubtree(doc);\[/code\]However this fails to canonicalize it properly, the attributes inside the xml tags are not reordered to have namespace first, as it should.Are there other ways to practically canonicalize xml on android?
 
Back
Top