List of utility methods to do XML QName
QName | convertToQName(String source, String nameSpaceuri) Code from Axis1 code base source = source.trim(); int colon = source.lastIndexOf(":"); String localPart = colon < 0 ? source : source.substring(colon + 1); String perfix = colon <= 0 ? "" : source.substring(0, colon); return new QName(nameSpaceuri, localPart, perfix); |
QName | copyQName(QName inName) copy Q Name if (inName == null) { return null; return new QName(inName.getNamespaceURI(), inName.getLocalPart()); |
QName | crackQName(String qName) Cracks a combined QName of the form URL:localname String ns; String name; int index = qName.lastIndexOf(':'); if (index >= 0) { ns = qName.substring(0, index); name = qName.substring(index + 1); } else { ns = ""; ... |
Collection | createCollection(QName... qnames) create Collection return Arrays.asList(qnames);
|
JAXBElement | createRootElement(T value, QName q_name, Class create Root Element return new JAXBElement<>(q_name, elementClass, null, value); |
Object | extract(final List extract for (final Object any : anyList) { if (any instanceof JAXBElement) { final JAXBElement elt = (JAXBElement) any; if ((classType != null && classType.equals(elt.getDeclaredType())) && (eltName != null && eltName.equals(elt.getName()))) { return elt.getValue(); return null; |
List | findAllElements(Element root, QName name, boolean local) find All Elements List<Node> list = new ArrayList<Node>(); if (matchNode(root, name, local)) list.add(root); for (Node child = root.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() != Node.ELEMENT_NODE) continue; list.addAll(findAllElements((Element) child, name, local)); return list; |
Element | findElement(QName elementName, List find Element for (Object o : content) { if (o instanceof Element) { Element u = (Element) o; QName n = new QName(u.getNamespaceURI(), u.getLocalName()); if (n.equals(elementName)) { return u; return null; |
Element | findElementRecursive(Element element, QName elementQName) find Element Recursive if (elementQName.equals(getQName(element))) { return element; for (Element subElement : listChildElements(element)) { Element foundElement = findElementRecursive(subElement, elementQName); if (foundElement != null) { return foundElement; return null; |
Node | findNode(Node node, QName name) Find a Node with a given QName if (name.getNamespaceURI().equals(node.getNamespaceURI()) && name.getLocalPart().equals(node.getLocalName())) return node; NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node ret = findNode(children.item(i), name); if (ret != null) return ret; ... |