Class DOMUtils
java.lang.Object
com.ibm.wsdl.util.xml.DOMUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcleanString(String orig) static intCount number of children of a certain type of the given element.static ElementfindChildElementWithAttribute(Element elem, String attrName, String attrValue) Return the first child element of the given element which has the given attribute with the given value.static StringgetAttribute(Element el, String attrName) Returns the value of an attribute of an element.static StringgetAttribute(Element el, String attrName, List remainingAttrs) Returns the value of an attribute of an element.static StringgetAttributeNS(Element el, String namespaceURI, String localPart) Returns the value of an attribute of an element.static ListgetAttributes(Element el) Returns a list of attributes of an element.static StringgetChildCharacterData(Element parentEl) Concat all the text and cdata node children of this elem and return the resulting text.static ElementgetFirstChildElement(Element elem) Return the first child element of the given element.static StringgetNamespaceURIFromPrefix(Node context, String prefix) Given a prefix and a node, return the namespace URI that the prefix has been associated with.static ElementgetNextSiblingElement(Element elem) Return the next sibling element of the given element.static StringgetPrefix(String namespaceURI, Definition def) static QNamegetQName(String prefixedValue, Element contextEl, Definition def) static QNamegetQualifiedAttributeValue(Element el, String attrName, String elDesc, boolean isRequired, Definition def) This method should be used for elements that support extension attributes because it does not track the remaining attributes to test for unexpected attributes.static QNamegetQualifiedAttributeValue(Element el, String attrName, String elDesc, boolean isRequired, Definition def, List remainingAttrs) This method should be used for elements that do not support extension attributes because it tracks the remaining attributes so that eventually any unexpected attributes can be identified.static StringgetQualifiedValue(String namespaceURI, String localPart, Definition def) static voidprintAttribute(String name, String value, PrintWriter pw) static voidprintQualifiedAttribute(String name, QName value, Definition def, PrintWriter pw) static voidprintQualifiedAttribute(QName name, String value, Definition def, PrintWriter pw) Prints attributes with qualified names.static voidprintQualifiedAttribute(QName name, QName value, Definition def, PrintWriter pw) static voidregisterUniquePrefix(String prefix, String namespaceURI, Definition def) static voidthrowWSDLException(Element location)
-
Constructor Details
-
DOMUtils
public DOMUtils()
-
-
Method Details
-
getAttributes
-
getAttribute
Returns the value of an attribute of an element. Returns null if the attribute is not found (whereas Element.getAttribute returns "" if an attrib is not found). This method should be used for elements that support extension attributes because it does not track unexpected attributes.- Parameters:
el- Element whose attrib is looked forattrName- name of attribute to look for- Returns:
- the attribute value
-
getAttribute
Returns the value of an attribute of an element. Returns null if the attribute is not found (whereas Element.getAttribute returns "" if an attrib is not found). This method should be used for elements that do not support extension attributes because it tracks the element's remaining attributes so that eventually any unexpected attributes can be identified.- Parameters:
el- Element whose attrib is looked forattrName- name of attribute to look forremainingAttrs- List of remaining attributes- Returns:
- the attribute value
-
getAttributeNS
Returns the value of an attribute of an element. Returns null if the attribute is not found (whereas Element.getAttributeNS returns "" if an attrib is not found).- Parameters:
el- Element whose attrib is looked fornamespaceURI- namespace URI of attribute to look forlocalPart- local part of attribute to look for- Returns:
- the attribute value
-
getChildCharacterData
-
getFirstChildElement
-
getNextSiblingElement
-
findChildElementWithAttribute
public static Element findChildElementWithAttribute(Element elem, String attrName, String attrValue) Return the first child element of the given element which has the given attribute with the given value.- Parameters:
elem- the element whose children are to be searchedattrName- the attrib that must be presentattrValue- the desired value of the attribute- Returns:
- the first matching child element.
-
countKids
Count number of children of a certain type of the given element.- Parameters:
elem- the element whose kids are to be counted- Returns:
- the number of matching kids.
-
getNamespaceURIFromPrefix
Given a prefix and a node, return the namespace URI that the prefix has been associated with. This method is useful in resolving the namespace URI of attribute values which are being interpreted as QNames. If prefix is null, this method will return the default namespace.- Parameters:
context- the starting node (looks up recursively from here)prefix- the prefix to find an xmlns:prefix=uri for- Returns:
- the namespace URI or null if not found
-
getQName
public static QName getQName(String prefixedValue, Element contextEl, Definition def) throws WSDLException - Throws:
WSDLException
-
registerUniquePrefix
-
getQualifiedAttributeValue
public static QName getQualifiedAttributeValue(Element el, String attrName, String elDesc, boolean isRequired, Definition def) throws WSDLException This method should be used for elements that support extension attributes because it does not track the remaining attributes to test for unexpected attributes.- Throws:
WSDLException
-
getQualifiedAttributeValue
public static QName getQualifiedAttributeValue(Element el, String attrName, String elDesc, boolean isRequired, Definition def, List remainingAttrs) throws WSDLException This method should be used for elements that do not support extension attributes because it tracks the remaining attributes so that eventually any unexpected attributes can be identified.- Throws:
WSDLException
-
throwWSDLException
- Throws:
WSDLException
-
printAttribute
-
printQualifiedAttribute
public static void printQualifiedAttribute(QName name, String value, Definition def, PrintWriter pw) throws WSDLException Prints attributes with qualified names.- Throws:
WSDLException
-
printQualifiedAttribute
public static void printQualifiedAttribute(QName name, QName value, Definition def, PrintWriter pw) throws WSDLException - Throws:
WSDLException
-
printQualifiedAttribute
public static void printQualifiedAttribute(String name, QName value, Definition def, PrintWriter pw) throws WSDLException - Throws:
WSDLException
-
getQualifiedValue
public static String getQualifiedValue(String namespaceURI, String localPart, Definition def) throws WSDLException - Throws:
WSDLException
-
getPrefix
- Throws:
WSDLException
-
cleanString
-