List of utility methods to do XML QName
Object | read(Node node, String expression, QName returnType) read XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression xPathExp = xpath.compile(expression);
return xPathExp.evaluate(node, returnType);
|
String | readTextElement(XMLEventReader reader, QName elemName) Reads the text content of an element. if (elemName != null) { requireStartElement(reader, elemName); String text = reader.getElementText(); reader.nextEvent(); return text; |
String | resolveNamespace(String qname, Node xml) Parses the prefix from the given qualified name and finds the first XML namespace declaration that maps that prefix to a namespace URI. int colonIndex = qname.indexOf(':'); String attributeName = XMLNS_PREFIX; if (colonIndex >= 0) { String prefix = qname.substring(0, colonIndex); attributeName += ':' + prefix; return searchParentNamespaces(xml, attributeName); |
QName | resolveQName(final Element el, final String qualifiedName) resolve Q Name QName qname; String prefix = ""; String namespaceURI = ""; String localPart = qualifiedName; final int colIndex = qualifiedName.indexOf(":"); if (colIndex > 0) { prefix = qualifiedName.substring(0, colIndex); localPart = qualifiedName.substring(colIndex + 1); ... |
QName | resolveQName(String qNameWithPrefix, Element element) resolve Q Name String nsPrefix; String localName; if (qNameWithPrefix.contains(":")) { String[] parts = qNameWithPrefix.split(":"); nsPrefix = parts[0]; localName = parts[1]; } else { nsPrefix = ""; ... |
void | search(List search if (nodeName == null) { list.add(baseElement); } else { QName qname; if (nodeName.getNamespaceURI().length() > 0) { qname = new QName(baseElement.getNamespaceURI(), baseElement.getLocalName()); } else { qname = new QName(baseElement.getLocalName()); ... |
Serializable | serializeJavaToXml(QName qname, Serializable value) serialize Java To Xml Serializable xmlData = null; if (value != null) { Class clazz = value.getClass(); JAXBContext jaxbContext = JAXBContext.newInstance(clazz); Marshaller marshaller = jaxbContext.createMarshaller(); Writer out = new StringWriter(); JAXBElement<Serializable> element = new JAXBElement<Serializable>(qname, clazz, value); marshaller.marshal(element, out); ... |
String | serializeQName(QName qName) serialize Q Name if (qName == null) { return ""; return qName.getNamespaceURI() + "#" + qName.getLocalPart(); |
void | setValue(java.util.Map set Value Optional<java.util.Map.Entry<QName, String>> attr = map.entrySet().stream() .filter((e) -> e.getKey().getLocalPart().equals(name)).findFirst(); if (attr.isPresent()) { attr.get().setValue(newValue); } else { map.put(new QName(name), newValue); |
String[] | splitQName(String qualifiedName) split Q Name if (qualifiedName == null) { throw new IllegalArgumentException("Null QName"); int idx = qualifiedName.indexOf(':'); String[] parts = { null, null }; if (idx >= 0) { parts[0] = qualifiedName.substring(0, idx); parts[1] = qualifiedName.substring(idx + 1); ... |