List of utility methods to do XML String Transform
String | encode(final String value) XML-encode a String final StringBuffer sb = new StringBuffer(); for (int i = 0; i < value.length(); ++i) { final char c = value.charAt(i); switch (c) { case '&': sb.append("&"); break; case '<': ... |
String | encodeStringIntoMemento(String str) Returns a XML memento, that encodes a single String parameter List<String> list = new ArrayList<>(); list.add(str); return encodeListIntoMemento(list); |
String | escapeBackslashes(String value) Escapes backslashes ('\') with additional backslashes in a given String, returning a new, escaped String. StringBuilder buf = new StringBuilder(value); for (int looper = 0; looper < buf.length(); looper++) { char curr = buf.charAt(looper); char next = 0; if (looper + 1 < buf.length()) next = buf.charAt(looper + 1); if (curr == '\\') { if (next != '\\') { ... |
LinkedHashMap | extractAndNormalizeEmbedPictures(String xmlFile, String odtFile, String parentDir, String imgBaseDir) Extract and normalize picture names, i.e. logger.fine("entering"); ZipFile zip; File imgDir; ArrayList<String> pics; DocumentBuilderFactory docFactory; DocumentBuilder docBuilder; Document contentDoc; LinkedHashMap<String, String> oldAndNewImgNames = new LinkedHashMap<String, String>(); ... |
String | extractElement(String xml, String tagName) extract Element InputSource xmlSource = new InputSource(new StringReader(xml)); return createXmlString(extractElement(createXmlDocument(xmlSource), tagName)); |
void | extractText(Node n, StringBuffer buf) extract Text if (n.getNodeType() == Node.TEXT_NODE) { buf.append(n.getNodeValue()); for (n = n.getFirstChild(); n != null; n = n.getNextSibling()) { extractText(n, buf); |
String | fileToXMLString(String filename) file To XML String return sourceToXMLString(new StreamSource(new File(filename))); |
String | getAsXMLString(final Node node) Transforms an org.w3c.dom.Document into a String final Transformer tf = TransformerFactory.newInstance().newTransformer(); final StringWriter stringWriter = new StringWriter(); tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); tf.transform(new DOMSource(node), new StreamResult(stringWriter)); return stringWriter.toString(); |
String | getBeanDefinition(String beanId, File file) get Bean Definition String beanDefinition = null; InputStream stream = null; try { stream = new FileInputStream(file); Element rootElement = loadRootElement(stream); beanDefinition = loadBeanDef(rootElement, beanId); } catch (Exception e) { throw e; ... |
String | getConfigurationAsXML(Map Get a set of properties as an XML Configuration DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); Element entity = doc.createElement("entity"); doc.appendChild(entity); for (Map.Entry<String, Object> element : properties.entrySet()) { String key = element.getKey(); Object value = element.getValue(); ... |