/** * {@inheritDoc} */ public synchronized Document getDescription() { // transform the string description as DOM one on first call since this // is not always used, takes time and memory! if ((this.description == null) && (this.stringDescription != null)) { this.description = XMLUtil.createDocumentFromString(this.stringDescription); } return this.description; }
/** * Create a String result from a DOM document * * @param document * the DOM Document. Must not be null * @return a String representation of the DOM Document * @throws TransformerException */ public static String createStringFromDOMDocument(final Node document) throws TransformerException { return createStringFromDOMNode(document, false); }
/** * Search for a child with the given nodeName. If recursive, search in all * the child of first level, then if not found, search in the 2nd level of * the first child, ... * * @param node * parent node * @param nodeName * node name * @param recursive * boolean to know if we got through the xml tree * @return a node */ public static Node findChild(final Node node, final String nodeName, final boolean recursive) { Node result = null; if ((node != null) && (nodeName != null)) { node.normalize(); NodeList nl = node.getChildNodes(); result = lookupNodeInNodeList(nodeName, nl); // now, search recursively if required if ((result == null) && recursive) { for (int i = 0; (i < nl.getLength()) && (result == null); i++) { result = findChild(nl.item(i), nodeName, true); } } } return result; }
try { wsdlDescriptionImports.put(uri.toString(), XMLUtil .createStringFromDOMDocument(imports.get(uri))); } catch (TransformerException e) {
/** * Return an array of String representing each Text element of the nodes * which are in the list. * * @param list * @return */ public static List<String> getTextContents(final NodeList list) { List<String> result = null; if (list != null) { result = new ArrayList<String>(); for (int i = 0; i < list.getLength(); i++) { Node pathElement = list.item(i); if (pathElement.getNodeType() != Node.TEXT_NODE) { result.add(getTextContent(pathElement)); } } } return result; }
/** * @param node * @param attrName * @return */ public static QName extractRequiredXmlAttributeQName(final Node node, final String attrName) { String attr = XMLUtil.getRequiredAttributeValue(node, attrName); QName qName = null; // qname like "xmlns:name" if ((attr.indexOf(':') > -1) && (attr.charAt(0) != '{')) { String ns = attr.substring(0, attr.indexOf(':')); String namespace = node.lookupNamespaceURI(ns); /* * String namespace = source.getDocumentElement().getAttribute( * "xmlns:" + ns); */ qName = new QName(namespace, attr.substring(attr.indexOf(':') + 1), ns); } else { // qname like "{ns}name" or "name" qName = QName.valueOf(attr); } return qName; }
/** * Create a node with the specified name, attributes and values. attVal is a * suite : att1,val1,att2,val2,... * * @param document * xlm document * @param nodeName * node name * @param attVal * attribute values * @return the node with its attribute, null if the array is not correct or * the document is null. */ public static Node createNode(final Document document, final String nodeName, final String... attVal) { Node element = null; if ((document != null) && (attVal.length % 2 == 0)) { element = document.createElement(nodeName); for (int i = 0; i < attVal.length; i = i + 2) { element.getAttributes().setNamedItem( createAttribute(document, attVal[i], attVal[i + 1])); } } return element; }
String attr = XMLUtil.getAttributeValue(node, attrName);
/** * Search for a child with the given nodeName. If recursive, search in all * the child of firdt level, then if not found, search in the 2nd level of * the first child, ... * * @param node * parent node * @param namespaceURI * The namespaceURI of the node * @param nodeName * node name * @param recursive * boolean to know if we got through the xml tree * @return a node */ public static Node findChild(final Node node, final String namespaceURI, final String nodeName, final boolean recursive) { node.normalize(); String prefix = node.lookupPrefix(namespaceURI); return findChild(node, prefix + nodeName, recursive); }
endpoint.setDescription(XMLUtil.createStringFromDOMDocument(serviceEndpoint .getDescription())); } catch (TransformerException e) {
endpoint.setSubDomain(serviceEndpoint.getLocation().getSubdomainName()); try { endpoint.setDescription(XMLUtil.createStringFromDOMDocument(serviceEndpoint .getDescription())); } catch (TransformerException e) {
/** * Create a String result from a DOM Node * * @param node * the DOM Node. Must not be null * @return a String representation of the DOM Document * @throws TransformerException */ public static String createStringFromDOMNode(final Node node) throws TransformerException { return createStringFromDOMNode(node, true); }