Package com.evolveum.midpoint.util
Class DOMUtil
java.lang.Object
com.evolveum.midpoint.util.DOMUtil
- Since:
- 0.1
- Author:
- Igor Farinic, Radovan Semancik
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Tracestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final QNamestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QNamestatic final QName
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionallNamespaceDeclarations(Node node) static voidcheckValidXmlChars(String stringValue) static booleancompareDocument(Document a, Document b, boolean considerNamespacePrefixes, boolean considerWhitespaces) static booleancompareElement(Element a, Element b, boolean considerNamespacePrefixes) static booleancompareElement(Element a, Element b, boolean considerNamespacePrefixes, boolean considerWhitespaces) static booleancompareElementList(List<Element> aList, List<Element> bList, boolean considerNamespacePrefixes) static booleancompareElementList(List<Element> aList, List<Element> bList, boolean considerNamespacePrefixes, boolean considerWhitespaces) static booleanstatic booleancompareTextNodeValues(String a, String b, boolean considerWhitespaces) static booleancontainsHTML(String code) Method to check if the code in the script element contains HTML.static voidcopyContent(Element source, Element destination) static voidcreateComment(Element element, String text) static DocumentBuilderstatic ElementcreateElement(QName qname) static ElementcreateElement(Document document, QName qname) static ElementcreateElement(Document document, QName qname, Element parentElement, Element definitionElement) static ElementcreateSubElement(Element parent, QName subElementQName) static Stringstatic ElementfindElementRecursive(Element element, QName elementQName) static voidfixNamespaceDeclarations(Element element) Take all the namespace declaration of parent elements and put them to this element.Returns all namespace declarations visible from the given node.static StringgetAttribute(Element element, String attrName) static StringgetAttribute(Element element, QName attrQname) static ElementgetChildElement(Element element, int index) static ElementgetChildElement(Element element, String localPart) static ElementgetChildElement(Element element, QName qname) getChildElements(Element element, QName elementName) static StringgetContentOfDocumentation(@NotNull String documentation) Parse documentation that contains xml tag 'documentation' to text of context onlystatic Documentstatic DocumentgetDocument(QName rootElementName) static DocumentgetDocument(Node node) getElement(Element root, QName... path) getElementsWithoutNamespacePrefix(Element element) static ElementgetFirstChildElement(Node parent) static IntegergetIntegerValue(Element element) static ElementgetLastChildElement(Node parent) static ElementgetMatchingChildElement(Element element, QName qname) getMatchingChildElements(Element element, QName qname) static ElementgetNamedElement(List<Element> elements, QName qname) static StringgetNamespaceDeclarationForPrefix(Element targetElement, String prefix) static Stringstatic StringgetNamespaceDeclarations(Element element) Returns map of all namespace declarations from specified element (prefix -> namespace).getNamespaceDeclarationsNonNull(Element element) static NodegetNextSiblingElement(Node node) static ElementgetOrCreateAsFirstElement(Element parentElement, QName elementQName) static ElementgetOrCreateSubElement(Document doc, Element parentElement, QName qName) static @NotNull QNamestatic QNamestatic QNamegetQNameAttribute(Element element, String attributeName) static QNamegetQNameAttribute(Element element, QName attributeName) static QNamegetQNameValue(String textContent, Map<String, String> namespaces) static QNamegetQNameValue(Attr attr) static QNamegetQNameValue(Element element) static QNamegetQNameWithoutPrefix(Node node) static StringgetSchemaTargetNamespace(Element xsdSchema) Should be synchronized.static booleanhasApplicationAttributes(Element element) static booleanhasChildElements(Node node) static booleanhasNamespaceDeclarationForPrefix(Element targetElement, String prefix) static booleanhasNoPrefix(Element top) static booleanhasXsiType(Element element) static booleanisElementName(Element element, QName name) static booleanstatic booleanstatic booleanstatic booleanisMarkedAsIncomplete(Element element) static booleanisNamespaceDefinition(Attr attr) static booleanstatic booleanisPrefixUsed(Element targetElement, String prefix) static Collection<Attr>listApplicationAttributes(Element element) listChildElements(Node node) Returned list contains non-null objects.static StringlookupOrCreateNamespaceDeclaration(Element element, String namespaceUri, String preferredPrefix, Element definitionElement, boolean allowUseOfDefaultNamespace) static voidstatic Documentparse(InputStream inputStream) static DocumentparseDocument(String doc) static Documentstatic Documentstatic voidpreserveFormattingIfPresent(Element xsdSchema) static StringBufferstatic StringBufferstatic voidremoveXsiType(Element element) static QNameresolveQName(com.evolveum.midpoint.util.DOMUtil.NamespaceResolver namespaceResolver, String qnameStringRepresentation) static QNameresolveQName(Element element) static QNameresolveQName(Node domNode, String qnameStringRepresentation) Resolves a QName.static QNameresolveXsiType(Element element) static voidserializeDOMToFile(Node node, File file) static StringserializeDOMToString(Node node) static StringserializeElementContent(Element element) Serializes the content of the element to a string (without the enclosing element tags).static voidsetAttributeValue(Element element, String name, String value) static voidsetElementTextContent(Element element, String value) static voidsetElementTextContentWithCDATAPrefix(Element element, String value) Method to create a child with a CDATA section for a DOM element.static voidsetNamespaceDeclaration(Element element, String prefix, String namespaceUri) static voidsetNamespaceDeclarations(Element element, Map<String, String> rootNamespaceDeclarations) static voidsetQNameAttribute(Element element, String attributeName, QName attributeValue) static voidsetQNameAttribute(Element element, String attributeName, QName attributeValue, Element definitionElement) static voidsetQNameAttribute(Element element, QName attributeName, QName attributeValue) static voidsetQNameAttribute(Element element, QName attributeName, QName attributeValue, Element definitionElement) static voidsetQNameValue(Element element, QName elementValue) Sets QName value for a given element.static TransformerFactorystatic voidsetXsiType(Element element, QName type) static Stringstatic voidvalidateNonEmptyQName(QName qname, String shortDescription, boolean allowEmptyNamespace) 
- 
Field Details- 
LOGGER
- 
W3C_XML_SCHEMA_XMLNS_URI- See Also:
 
- 
W3C_XML_SCHEMA_XMLNS_PREFIX- See Also:
 
- 
W3C_XML_XML_URI- See Also:
 
- 
W3C_XML_XML_PREFIX- See Also:
 
- 
NS_W3C_XSI_PREFIX- See Also:
 
- 
XSI_TYPE
- 
XSI_NIL
- 
HACKED_XSI_TYPE- See Also:
 
- 
IS_LIST_ATTRIBUTE_NAME- See Also:
 
- 
IS_INCOMPLETE_ATTRIBUTE_NAME- See Also:
 
- 
NS_W3C_XML_SCHEMA_PREFIX- See Also:
 
- 
XSD_SCHEMA_ELEMENT
- 
XSD_ANNOTATION_ELEMENT
- 
XSD_APPINFO_ELEMENT
- 
XSD_DOCUMENTATION_ELEMENT
- 
XSD_IMPORT_ELEMENT
- 
XSD_INCLUDE_ELEMENT
- 
XSD_ATTR_TARGET_NAMESPACE
- 
XSD_ATTR_NAMESPACE
- 
XSD_ATTR_SCHEMA_LOCATION
- 
XSD_DECIMAL
- 
XSD_STRING
- 
XSD_INTEGER
- 
XSD_INT
- 
XSD_LONG
- 
XSD_SHORT
- 
XSD_FLOAT
- 
XSD_DOUBLE
- 
XSD_BOOLEAN
- 
XSD_BASE64BINARY
- 
XSD_DATETIME
- 
XSD_DURATION
- 
XSD_BYTE
- 
XSD_QNAME
- 
XSD_ANYURI
- 
XSD_ANY
- 
XSD_ANYTYPE
- 
NS_WSDL- See Also:
 
- 
NS_WSDL_SCHEMA_PREFIX- See Also:
 
- 
WSDL_IMPORT_ELEMENT
- 
WSDL_TYPES_ELEMENT
- 
WSDL_ATTR_NAMESPACE
- 
WSDL_ATTR_LOCATION
- 
SCRIPT_CODE_ELEMENT_NAME
 
- 
- 
Constructor Details- 
DOMUtilpublic DOMUtil()
 
- 
- 
Method Details- 
setupTransformerFactory
- 
serializeDOMToString
- 
serializeDOMToFilepublic static void serializeDOMToFile(Node node, File file) throws TransformerFactoryConfigurationError, TransformerException 
- 
getDocument
- 
getDocument
- 
getDocument
- 
createDocumentBuilder
- 
parseDocument
- 
parseFile
- 
parseFile
- 
parse- Throws:
- IOException
 
- 
showDom
- 
printDom
- 
printDom
- 
getNextSiblingElement
- 
getFirstChildElement
- 
getLastChildElement
- 
getChildElements
- 
listChildElementsReturned list contains non-null objects.
- 
hasChildElements
- 
resolveQName
- 
resolveQNameResolves a QName. Contrary to traditional XML handling, a QName without prefix is parsed to a QName without namespace, even if default namespace declaration is present.- Parameters:
- 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)
- Returns:
- parsed QName (or null if string representation is blank)
 
- 
isMarkedAsIncomplete
- 
getSchemaTargetNamespaceShould be synchronized. This is the responsibility of the caller. See MID-8860.- Throws:
- SchemaException
 
- 
preserveFormattingIfPresent
- 
resolveQName
- 
resolveXsiType
- 
hasXsiType
- 
removeXsiType
- 
setXsiType
- 
setQNameAttribute
- 
setQNameAttribute
- 
setQNameAttribute
- 
setQNameAttribute
- 
setQNameValueSets QName value for a given element.Contrary to standard XML semantics, namespace-less QNames are specified as simple names without prefix (regardless of default prefix used in the XML document). - Parameters:
- element- Element whose text content should be set to represent QName value
- elementValue- QName value to be stored into the element
 
- 
lookupOrCreateNamespaceDeclarationpublic static String lookupOrCreateNamespaceDeclaration(Element element, String namespaceUri, String preferredPrefix, Element definitionElement, boolean allowUseOfDefaultNamespace) - Parameters:
- element- Element, on which the namespace declaration is evaluated
- namespaceUri- Namespace URI to be assigned to a prefix
- preferredPrefix- Preferred prefix
- definitionElement- 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 setQNameValue
- Returns:
- prefix that is really used
 Returned prefix is never null nor "" if allowUseOfDefaultNamespace is false. 
 
- 
isNamespaceDefinition
- 
setNamespaceDeclaration
- 
getNamespaceDeclarationsReturns map of all namespace declarations from specified element (prefix -> namespace).
- 
getNamespaceDeclarationsNonNull
- 
setNamespaceDeclarations
- 
getAllVisibleNamespaceDeclarationsReturns all namespace declarations visible from the given node. Uses recursion for simplicity.
- 
getAllNonDefaultNamespaceDeclarations
- 
allNamespaceDeclarations
- 
fixNamespaceDeclarationsTake all the namespace declaration of parent elements and put them to this element.
- 
isPrefixUsed
- 
hasNamespaceDeclarationForPrefix
- 
getNamespaceDeclarationForPrefix
- 
getNamespaceDeclarationPrefix
- 
getNamespaceDeclarationNamespace
- 
listApplicationAttributes
- 
hasApplicationAttributes
- 
getChildElement
- 
getElement
- 
getMatchingChildElement
- 
getMatchingChildElements
- 
getNamedElement
- 
getChildElement
- 
getChildElement
- 
getOrCreateAsFirstElement
- 
getQName
- 
getQName
- 
getQNameValue
- 
getQNameValue
- 
getQNameAttribute
- 
getQNameAttribute
- 
getQNameValue
- 
getIntegerValue
- 
copyContent
- 
createElement
- 
createElement
- 
createElement
- 
createSubElement
- 
compareElement
- 
compareElement
- 
compareDocument
- 
compareElementList
- 
compareElementList
- 
compareTextNodeValues
- 
compareTextNodeValues
- 
normalize
- 
isJunk
- 
validateNonEmptyQName
- 
findElementRecursive
- 
getQNameWithoutPrefix
- 
isElementName
- 
isNil
- 
serializeElementContentSerializes the content of the element to a string (without the enclosing element tags).
- 
isEmpty
- 
isEmpty
- 
setAttributeValue
- 
setElementTextContent
- 
setElementTextContentWithCDATAPrefixMethod to create a child with a CDATA section for a DOM element.- Parameters:
- element- The DOM element for which a child element with a CDATA section will be created.
- value- The value that will be wrapped in the CDATA section.
 
- 
containsHTMLMethod to check if the code in the script element contains HTML.
- 
checkValidXmlChars
- 
escapeInvalidXmlCharsIfPresent
- 
createComment
- 
getAttribute
- 
getAttribute
- 
hasNoPrefix
- 
getElementsWithoutNamespacePrefix
- 
getContentOfDocumentationParse documentation that contains xml tag 'documentation' to text of context only
- 
getOrCreateSubElement
 
-