public class DOMUtil extends Object
Constructor and Description |
---|
DOMUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
checkValidXmlChars(String stringValue) |
static boolean |
compareDocument(Document a,
Document b,
boolean considerNamespacePrefixes,
boolean considerWhitespaces) |
static boolean |
compareElement(Element a,
Element b,
boolean considerNamespacePrefixes) |
static boolean |
compareElement(Element a,
Element b,
boolean considerNamespacePrefixes,
boolean considerWhitespaces) |
static boolean |
compareElementList(List<Element> aList,
List<Element> bList,
boolean considerNamespacePrefixes) |
static boolean |
compareElementList(List<Element> aList,
List<Element> bList,
boolean considerNamespacePrefixes,
boolean considerWhitespaces) |
static boolean |
compareTextNodeValues(String a,
String b) |
static boolean |
compareTextNodeValues(String a,
String b,
boolean considerWhitespaces) |
static void |
copyContent(Element source,
Element destination) |
static void |
createComment(Element element,
String text) |
static DocumentBuilder |
createDocumentBuilder() |
static Element |
createElement(Document document,
QName qname) |
static Element |
createElement(Document document,
QName qname,
Element parentElement,
Element definitionElement) |
static Element |
createElement(QName qname) |
static Element |
createSubElement(Element parent,
QName subElementQName) |
static Element |
findElementRecursive(Element element,
QName elementQName) |
static String |
findNamespace(Node domNode,
String prefix) |
static void |
fixNamespaceDeclarations(Element element)
Take all the namespace declaration of parent elements and put them to this element.
|
static Map<String,String> |
getAllVisibleNamespaceDeclarations(Node node)
Returns all namespace declarations visible from the given node.
|
static String |
getAttribute(Element element,
QName attrQname) |
static Element |
getChildElement(Element element,
int index) |
static Element |
getChildElement(Element element,
QName qname) |
static Element |
getChildElement(Element element,
String localPart) |
static List<Element> |
getChildElements(Element element,
QName elementName) |
static Document |
getDocument() |
static Document |
getDocument(Node node) |
static Document |
getDocument(QName rootElementName) |
static Element |
getFirstChildElement(Node parent) |
static Integer |
getIntegerValue(Element element) |
static Element |
getLastChildElement(Node parent) |
static String |
getNamespaceDeclarationForPrefix(Element targetElement,
String prefix) |
static String |
getNamespaceDeclarationNamespace(Attr attr) |
static String |
getNamespaceDeclarationPrefix(Attr attr) |
static Map<String,String> |
getNamespaceDeclarations(Element element)
Returns map of all namespace declarations from specified element (prefix -> namespace).
|
static Node |
getNextSiblingElement(Node node) |
static Element |
getOrCreateAsFirstElement(Element parentElement,
QName elementQName) |
static QName |
getQName(Node node) |
static QName |
getQNameAttribute(Element element,
QName attributeName) |
static QName |
getQNameAttribute(Element element,
String attributeName) |
static QName |
getQNameValue(Attr attr) |
static QName |
getQNameValue(Element element) |
static QName |
getQNameWithoutPrefix(Node node) |
static boolean |
hasApplicationAttributes(Element element) |
static boolean |
hasChildElements(Node node) |
static boolean |
hasNamespaceDeclarationForPrefix(Element targetElement,
String prefix) |
static boolean |
hasXsiType(Element element) |
static boolean |
isElementName(Element element,
QName name) |
static boolean |
isEmpty(Attr attr) |
static boolean |
isEmpty(Element element) |
static boolean |
isJunk(Node node) |
static boolean |
isNamespaceDefinition(Attr attr) |
static boolean |
isNil(Element element) |
static boolean |
isPrefixUsed(Element targetElement,
String prefix) |
static Collection<Attr> |
listApplicationAttributes(Element element) |
static List<Element> |
listChildElements(Node node) |
static String |
lookupOrCreateNamespaceDeclaration(Element element,
String namespaceUri,
String preferredPrefix,
Element definitionElement,
boolean allowUseOfDefaultNamespace) |
static void |
normalize(Node node,
boolean keepWhitespaces) |
static Document |
parse(InputStream inputStream) |
static Document |
parseDocument(String doc) |
static Document |
parseFile(File file) |
static Document |
parseFile(String filePath) |
static StringBuffer |
printDom(Node node) |
static StringBuffer |
printDom(Node node,
boolean indent,
boolean omitXmlDeclaration) |
static void |
removeXsiType(Element element) |
static QName |
resolveQName(Element element) |
static QName |
resolveQName(Node domNode,
String qnameStringRepresentation)
Resolves a QName.
|
static QName |
resolveXsiType(Element element) |
static void |
serializeDOMToFile(Node node,
File file) |
static String |
serializeDOMToString(Node node) |
static String |
serializeElementContent(Element element)
Serializes the content of the element to a string (without the eclosing element tags).
|
static void |
setAttributeValue(Element element,
String name,
String value) |
static void |
setElementTextContent(Element element,
String value) |
static void |
setNamespaceDeclaration(Element element,
String prefix,
String namespaceUri) |
static void |
setNamespaceDeclarations(Element element,
Map<String,String> rootNamespaceDeclarations) |
static void |
setNill(Element element) |
static void |
setQNameAttribute(Element element,
QName attributeName,
QName attributeValue) |
static void |
setQNameAttribute(Element element,
QName attributeName,
QName attributeValue,
Element definitionElement) |
static void |
setQNameAttribute(Element element,
String attributeName,
QName attributeValue) |
static void |
setQNameAttribute(Element element,
String attributeName,
QName attributeValue,
Element definitionElement) |
static void |
setQNameValue(Element element,
QName elementValue)
Sets QName value for a given element.
|
static void |
setXsiType(Element element,
QName type) |
static String |
showDom(List<Element> elements) |
static void |
validateNonEmptyQName(QName qname,
String shortDescription,
boolean allowEmptyNamespace) |
public static final Trace LOGGER
public static final String W3C_XML_SCHEMA_XMLNS_URI
public static final String W3C_XML_SCHEMA_XMLNS_PREFIX
public static final String W3C_XML_XML_URI
public static final String W3C_XML_XML_PREFIX
public static final String NS_W3C_XSI_PREFIX
public static final QName XSI_TYPE
public static final QName XSI_NIL
public static final QName XML_ID_ATTRIBUTE
public static final String HACKED_XSI_TYPE
public static final String NS_W3C_XML_SCHEMA_PREFIX
public static final QName XSD_SCHEMA_ELEMENT
public static final QName XSD_ANNOTATION_ELEMENT
public static final QName XSD_APPINFO_ELEMENT
public static final QName XSD_DOCUMENTATION_ELEMENT
public static final QName XSD_IMPORT_ELEMENT
public static final QName XSD_INCLUDE_ELEMENT
public static final QName XSD_ATTR_TARGET_NAMESPACE
public static final QName XSD_ATTR_NAMESPACE
public static final QName XSD_ATTR_SCHEMA_LOCATION
public static final QName XSD_DECIMAL
public static final QName XSD_STRING
public static final QName XSD_INTEGER
public static final QName XSD_INT
public static final QName XSD_LONG
public static final QName XSD_SHORT
public static final QName XSD_FLOAT
public static final QName XSD_DOUBLE
public static final QName XSD_BOOLEAN
public static final QName XSD_BASE64BINARY
public static final QName XSD_DATETIME
public static final QName XSD_DURATION
public static final QName XSD_BYTE
public static final QName XSD_QNAME
public static final QName XSD_ANYURI
public static final QName XSD_ANY
public static final QName XSD_ANYTYPE
public static final String NS_XML_ENC
public static final String NS_XML_DSIG
public static final String NS_WSDL
public static final String NS_WSDL_SCHEMA_PREFIX
public static final QName WSDL_IMPORT_ELEMENT
public static final QName WSDL_TYPES_ELEMENT
public static final QName WSDL_ATTR_NAMESPACE
public static final QName WSDL_ATTR_SCHEMA_LOCATION
public static final QName WSDL_ATTR_LOCATION
public static void serializeDOMToFile(Node node, File file) throws TransformerFactoryConfigurationError, TransformerException
public static Document getDocument()
public static DocumentBuilder createDocumentBuilder()
public static Document parse(InputStream inputStream) throws IOException
IOException
public static StringBuffer printDom(Node node)
public static StringBuffer printDom(Node node, boolean indent, boolean omitXmlDeclaration)
public static boolean hasChildElements(Node node)
public static QName resolveQName(Node domNode, String qnameStringRepresentation)
domNode
- Provides a context in which we will resolve namespace prefixes (may be null)qnameStringRepresentation
- String representation of a QName (e.g. c:RoleType) (may be null)public static boolean hasXsiType(Element element)
public static void removeXsiType(Element element)
public static void setQNameAttribute(Element element, QName attributeName, QName attributeValue)
public static void setQNameAttribute(Element element, String attributeName, QName attributeValue)
public static void setQNameAttribute(Element element, QName attributeName, QName attributeValue, Element definitionElement)
public static void setQNameAttribute(Element element, String attributeName, QName attributeValue, Element definitionElement)
public static void setQNameValue(Element element, QName elementValue)
element
- Element whose text content should be set to represent QName valueelementValue
- QName value to be stored into the elementpublic static String lookupOrCreateNamespaceDeclaration(Element element, String namespaceUri, String preferredPrefix, Element definitionElement, boolean allowUseOfDefaultNamespace)
element
- Element, on which the namespace declaration is evaluatednamespaceUri
- Namespace URI to be assigned to a prefixpreferredPrefix
- Preferred prefixdefinitionElement
- Element, on which namespace declaration will be created (there should not be any redefinitions between definitionElement and element in order for this to work...)allowUseOfDefaultNamespace
- If we are allowed to use default namespace (i.e. return empty prefix). This is important for QNames, see setQNameValuepublic static boolean isNamespaceDefinition(Attr attr)
public static void setNamespaceDeclaration(Element element, String prefix, String namespaceUri)
public static Map<String,String> getNamespaceDeclarations(Element element)
public static void setNamespaceDeclarations(Element element, Map<String,String> rootNamespaceDeclarations)
public static Map<String,String> getAllVisibleNamespaceDeclarations(Node node)
public static void fixNamespaceDeclarations(Element element)
public static boolean hasNamespaceDeclarationForPrefix(Element targetElement, String prefix)
public static String getNamespaceDeclarationForPrefix(Element targetElement, String prefix)
public static Collection<Attr> listApplicationAttributes(Element element)
public static boolean hasApplicationAttributes(Element element)
public static Element getOrCreateAsFirstElement(Element parentElement, QName elementQName)
public static Element createElement(Document document, QName qname, Element parentElement, Element definitionElement)
public static boolean compareElement(Element a, Element b, boolean considerNamespacePrefixes)
public static boolean compareElement(Element a, Element b, boolean considerNamespacePrefixes, boolean considerWhitespaces)
public static boolean compareDocument(Document a, Document b, boolean considerNamespacePrefixes, boolean considerWhitespaces)
public static boolean compareElementList(List<Element> aList, List<Element> bList, boolean considerNamespacePrefixes)
public static boolean compareElementList(List<Element> aList, List<Element> bList, boolean considerNamespacePrefixes, boolean considerWhitespaces)
public static boolean compareTextNodeValues(String a, String b, boolean considerWhitespaces)
public static void normalize(Node node, boolean keepWhitespaces)
public static boolean isJunk(Node node)
public static void validateNonEmptyQName(QName qname, String shortDescription, boolean allowEmptyNamespace)
public static Element findElementRecursive(Element element, QName elementQName)
public static boolean isNil(Element element)
public static void setNill(Element element)
public static String serializeElementContent(Element element)
public static boolean isEmpty(Element element)
public static boolean isEmpty(Attr attr)
public static void checkValidXmlChars(String stringValue)
Copyright © 2016 evolveum. All rights reserved.