Package org.identityconnectors.common
Class XmlUtil
java.lang.Object
org.identityconnectors.common.XmlUtil
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
static final char
static final char
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
escape
(StringBuilder b, String s, char delim) Escapes the given string and appends to the given bufferstatic Element
findImmediateChildElement
(Node node, String name) Find an immediate child of the given namestatic String
getAttribute
(Element e, String name) Return the value of an attribute on an element.static String
Return the content of the given element.static Element
getFirstChildElement
(Node node) Returns the First child element or null if none foundstatic Element
getNextElement
(Node node) Get the next right sibling that is an element.static Document
parseString
(String xml) Parses a string without validation and returns the Document.
-
Field Details
-
NO_DELIM
public static final char NO_DELIM- See Also:
-
DOUBLE_QUOTE
public static final char DOUBLE_QUOTE- See Also:
-
SINGLE_QUOTE
public static final char SINGLE_QUOTE- See Also:
-
-
Method Details
-
parseString
public static Document parseString(String xml) throws IOException, SAXException, ParserConfigurationException Parses a string without validation and returns the Document. -
getAttribute
Return the value of an attribute on an element.The DOM getAttribute method returns an empty string if the attribute doesn't exist. Here, we detect this and return null.
-
findImmediateChildElement
Find an immediate child of the given name -
getFirstChildElement
Returns the First child element or null if none found- Parameters:
node
- The node. May be null.- Returns:
- the First child element or null if none found
-
getNextElement
Get the next right sibling that is an element. -
getContent
Return the content of the given element.We will descend to an arbitrary depth looking for the first text node.
Note that the parser may break what was originally a single string of pcdata into multiple adjacent text nodes. Xerces appears to do this when it encounters a '$' in the text, not sure if there is specified behavior, or if its parser specific.
Here, we will congeal adjacent text nodes.
We will NOT ignore text nodes that have only whitespace.
-
escape
Escapes the given string and appends to the given buffer- Parameters:
b
- The buffers
- The script to be escaped. May be null.delim
- May beSINGLE_QUOTE
,DOUBLE_QUOTE
, orNO_DELIM
.
-