(byte[] data)
| 89 | } |
| 90 | |
| 91 | private byte[] xmlLint(byte[] data) { |
| 92 | try { |
| 93 | |
| 94 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
| 95 | dbf.setValidating(false); |
| 96 | DocumentBuilder db = dbf.newDocumentBuilder(); |
| 97 | db.setErrorHandler(new IgnoreErrorMsgHandler()); |
| 98 | InputSource is = new InputSource(new StringReader(new String(data))); |
| 99 | Document doc = db.parse(is); |
| 100 | Transformer transformer = TransformerFactory.newInstance().newTransformer(); |
| 101 | transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); |
| 102 | transformer.setOutputProperty(OutputKeys.INDENT, "yes"); |
| 103 | transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); |
| 104 | StreamResult result = new StreamResult(new StringWriter()); |
| 105 | DOMSource source = new DOMSource(doc); |
| 106 | transformer.transform(source, result); |
| 107 | return result.getWriter().toString().getBytes(StandardCharsets.UTF_8); |
| 108 | } catch (Exception e) { |
| 109 | |
| 110 | return data; |
| 111 | } |
| 112 | } |
| 113 | } |
no test coverage detected