/** * Serialise the supplied W3C DOM subtree. * <p/> * The output is unformatted. * * @param nodeList The DOM subtree as a NodeList. * @return The subtree in serailised form. * @throws DOMException Unable to serialise the DOM. */ public static String serialize(NodeList nodeList) throws DOMException { return serialize(nodeList, false); }
/** * Basic DOM namespace aware parse. * @param stream Document stream. * @return Document instance. */ public static Document parseStream(Reader stream) throws ParserConfigurationException, IOException, SAXException { return XmlUtil.parseStream(stream, null); }
/** * Remove all entities from the supplied <code>String</code> stream * replacing them with there actual character values. * * @param string The string on which the operation is to be carried out. * @return The string with its entities rewriten. */ public static String removeEntities(String string) { if (string == null) { throw new IllegalArgumentException("null string arg"); } try { StringReader reader = new StringReader(string); StringWriter writer = new StringWriter(); XmlUtil.removeEntities(reader, writer); return writer.toString(); } catch (Exception excep) { excep.printStackTrace(); return string; } }
/** * Get the String data associated with the XPath selection supplied. * * @param node The node to be searched. * @param xpath The XPath String to be used in the selection. * @return The string data located at the specified location in the * document, or an empty string for an empty resultset query. */ public static String getString(Node node, String xpath) { NodeList nodeList = getNodeList(node, xpath); if (nodeList == null || nodeList.getLength() == 0) { return ""; } if (xpath.endsWith(ELEMENT_NAME_FUNC)) { if (nodeList.getLength() > 0) { return nodeList.item(0).getNodeName(); } else { return ""; } } else { return serialize(nodeList); } }
@Override public void serialize(Writer outputStream, SerializationContext context) throws IOException { String value = getValue(context); if(value != null) { outputStream.write(" "); writeName(outputStream); outputStream.write("=\""); char[] characters = value.toCharArray(); XmlUtil.encodeAttributeValue(characters, 0, characters.length, outputStream); outputStream.write('"'); } }
public void writeElementText(Text text, Writer writer, ExecutionContext executionContext) throws IOException { if(rewriteEntities) { String textString = text.getData(); XmlUtil.encodeTextValue(textString.toCharArray(), 0, textString.length(), writer); } else { writer.write(text.getData()); } }
String resourceSelector; currentElement = (Element) XmlUtil.getNode(configDoc, "/smooks-resource-list"); String defaultSelector = DomUtils.getAttributeValue(currentElement, "default-selector"); String defaultNamespace = DomUtils.getAttributeValue(currentElement, "default-namespace"); while ((currentElement = (Element) XmlUtil.getNode(configDoc, resourceSelector)) != null) { String selector = DomUtils.getAttributeValue(currentElement, "selector"); String namespace = DomUtils.getAttributeValue(currentElement, "namespace");
/** * Create an element with the specified name. * @param localPart The localPart name. * @return Element instance. */ public static Element createElement(String localPart) { return createElementNS(XMLConstants.NULL_NS_URI, localPart); }
/** * Get the String data associated with the XPath selection supplied. * * @param node The node to be searched. * @param xpath The XPath String to be used in the selection. * @return The string data located at the specified location in the * document, or an empty string for an empty resultset query. */ public static String getString(Node node, String xpath) { NodeList nodeList = getNodeList(node, xpath); if (nodeList == null || nodeList.getLength() == 0) { return ""; } if (xpath.endsWith(ELEMENT_NAME_FUNC)) { if (nodeList.getLength() > 0) { return nodeList.item(0).getNodeName(); } else { return ""; } } else { return serialize(nodeList); } }
@Override public void serialize(Writer outputStream, SerializationContext context) throws IOException { String value = getValue(context); if(value != null) { outputStream.write(" "); writeName(outputStream); outputStream.write("=\""); char[] characters = value.toCharArray(); XmlUtil.encodeAttributeValue(characters, 0, characters.length, outputStream); outputStream.write('"'); } }
public void writeElementText(Text text, Writer writer, ExecutionContext executionContext) throws IOException { if(rewriteEntities) { String textString = text.getData(); XmlUtil.encodeTextValue(textString.toCharArray(), 0, textString.length(), writer); } else { writer.write(text.getData()); } }
String resourceSelector; currentElement = (Element) XmlUtil.getNode(configDoc, "/smooks-resource-list"); String defaultSelector = DomUtils.getAttributeValue(currentElement, "default-selector"); String defaultNamespace = DomUtils.getAttributeValue(currentElement, "default-namespace"); while ((currentElement = (Element) XmlUtil.getNode(configDoc, resourceSelector)) != null) { String selector = DomUtils.getAttributeValue(currentElement, "selector"); String namespace = DomUtils.getAttributeValue(currentElement, "namespace");
/** * Create an element with the specified name. * @param localPart The localPart name. * @return Element instance. */ public static Element createElement(String localPart) { return createElementNS(XMLConstants.NULL_NS_URI, localPart); }
/** * Serialise the supplied W3C DOM subtree. * <p/> * The output is unformatted. * * @param nodeList The DOM subtree as a NodeList. * @return The subtree in serailised form. * @throws DOMException Unable to serialise the DOM. */ public static String serialize(NodeList nodeList) throws DOMException { return serialize(nodeList, false); }
/** * Basic DOM namespace aware parse. * @param stream Document stream. * @return Document instance. */ public static Document parseStream(Reader stream) throws ParserConfigurationException, IOException, SAXException { return XmlUtil.parseStream(stream, null); }
/** * Remove all entities from the supplied <code>String</code> stream * replacing them with there actual character values. * * @param string The string on which the operation is to be carried out. * @return The string with its entities rewriten. */ public static String removeEntities(String string) { if (string == null) { throw new IllegalArgumentException("null string arg"); } try { StringReader reader = new StringReader(string); StringWriter writer = new StringWriter(); XmlUtil.removeEntities(reader, writer); return writer.toString(); } catch (Exception excep) { excep.printStackTrace(); return string; } }
/** * Get the String data associated with the XPath selection supplied. * * @param node The node to be searched. * @param xpath The XPath String to be used in the selection. * @return The string data located at the specified location in the * document, or an empty string for an empty resultset query. */ public static String getString(Node node, String xpath) { NodeList nodeList = getNodeList(node, xpath); if (nodeList == null || nodeList.getLength() == 0) { return ""; } if (xpath.endsWith(ELEMENT_NAME_FUNC)) { if (nodeList.getLength() > 0) { return nodeList.item(0).getNodeName(); } else { return ""; } } else { return serialize(nodeList); } }
@Override public void serialize(Writer outputStream, SerializationContext context) throws IOException { String value = getValue(context); if(value != null) { outputStream.write(" "); writeName(outputStream); outputStream.write("=\""); char[] characters = value.toCharArray(); XmlUtil.encodeAttributeValue(characters, 0, characters.length, outputStream); outputStream.write('"'); } }
public void writeElementText(Text text, Writer writer, ExecutionContext executionContext) throws IOException { if(rewriteEntities) { String textString = text.getData(); XmlUtil.encodeTextValue(textString.toCharArray(), 0, textString.length(), writer); } else { writer.write(text.getData()); } }
String resourceSelector; currentElement = (Element) XmlUtil.getNode(configDoc, "/smooks-resource-list"); String defaultSelector = DomUtils.getAttributeValue(currentElement, "default-selector"); String defaultNamespace = DomUtils.getAttributeValue(currentElement, "default-namespace"); while ((currentElement = (Element) XmlUtil.getNode(configDoc, resourceSelector)) != null) { String selector = DomUtils.getAttributeValue(currentElement, "selector"); String namespace = DomUtils.getAttributeValue(currentElement, "namespace");