public abstract class XmlUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
XmlUtil.ElementListIterator
_more_
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NULL_STRING
Just so we don't have to do (String) null.
|
static java.lang.String |
TAG_WILDCARD
used for matching any tag
|
static java.lang.String |
XML_HEADER
The header to use when writing out xml
|
Constructor and Description |
---|
XmlUtil()
Dummy ctor for doclint.
|
Modifier and Type | Method and Description |
---|---|
static void |
addChildren(org.w3c.dom.Element element,
java.util.List children)
Append the given list of children Elements to the given Element.
|
static void |
appendCdata(java.lang.StringBuffer sb,
java.lang.String s)
_more_
|
static void |
appendCdataBytes(java.lang.StringBuffer sb,
byte[] bytes)
_more_
|
static void |
attr(java.lang.Appendable buff,
java.lang.String name,
java.lang.String value,
java.lang.String tab)
Append onto the given StringBuffer name="value" string encode the value.
|
static java.lang.String |
attr(java.lang.String name,
java.lang.String value)
Return a String with name="value".
|
static java.lang.String |
attrs(java.lang.String[] attrs)
_more_
|
static java.lang.String |
attrs(java.lang.String name,
java.lang.String value)
_more_
|
static java.lang.String |
attrs(java.lang.String n1,
java.lang.String v1,
java.lang.String n2,
java.lang.String v2)
Return a String with n1="v1" n2="v2".
|
static java.lang.String |
attrs(java.lang.String n1,
java.lang.String v1,
java.lang.String n2,
java.lang.String v2,
java.lang.String n3,
java.lang.String v3)
Return a String with n1="v1" n2="v2".
|
static java.lang.String |
attrs(java.lang.String n1,
java.lang.String v1,
java.lang.String n2,
java.lang.String v2,
java.lang.String n3,
java.lang.String v3,
java.lang.String n4,
java.lang.String v4)
Return a String with n1="v1" n2="v2".
|
static java.lang.String |
calculateRFC2104HMAC(java.lang.String data,
java.lang.String key)
Computes RFC 2104-compliant HMAC signature.
|
static java.lang.String |
closeTag(java.lang.String name)
Make a close tag
|
static java.lang.String |
comment(java.lang.String value)
Create and return an xml comment.
|
static org.w3c.dom.Element |
create(org.w3c.dom.Document doc,
java.lang.String tag)
_more_
|
static org.w3c.dom.Element |
create(org.w3c.dom.Document doc,
java.lang.String tag,
org.w3c.dom.Element parent)
_more_
|
static org.w3c.dom.Element |
create(org.w3c.dom.Document doc,
java.lang.String tag,
org.w3c.dom.Element parent,
java.util.List attrs)
_more_
|
static org.w3c.dom.Element |
create(org.w3c.dom.Document doc,
java.lang.String tag,
org.w3c.dom.Element parent,
java.lang.String text)
_more_
|
static org.w3c.dom.Element |
create(org.w3c.dom.Document doc,
java.lang.String tag,
org.w3c.dom.Element parent,
java.lang.String[] attrs)
_more_
|
static org.w3c.dom.Element |
create(org.w3c.dom.Document doc,
java.lang.String tag,
org.w3c.dom.Element parent,
java.lang.String text,
java.lang.String[] attrs)
_more_
|
static org.w3c.dom.Element |
create(org.w3c.dom.Document doc,
java.lang.String tag,
java.lang.String[] attrs)
_more_
|
static org.w3c.dom.Element |
create(java.lang.String tag,
org.w3c.dom.Element parent)
_more_
|
static org.w3c.dom.Element |
create(java.lang.String tag,
org.w3c.dom.Element parent,
java.util.List attrs)
_more_
|
static org.w3c.dom.Element |
create(java.lang.String tag,
org.w3c.dom.Element parent,
java.lang.String text)
_more_
|
static org.w3c.dom.Element |
create(java.lang.String tag,
org.w3c.dom.Element parent,
java.lang.String[] attrs)
_more_
|
static org.w3c.dom.Element |
create(java.lang.String tag,
org.w3c.dom.Element parent,
java.lang.String text,
java.lang.String[] attrs)
_more_
|
static void |
createCDataNode(org.w3c.dom.Element parent,
java.lang.String text)
_more_
|
static byte[] |
decodeBase64(java.lang.String s)
Decode the given base64 String
|
static XmlUtil.ElementListIterator |
elements(java.lang.String xmlFile,
java.lang.String xPath)
_more_
|
static java.lang.String |
encodeBase64(byte[] b)
Return the base64 encoded representation of the given byte array
|
static java.lang.String |
encodeString(java.lang.String v)
Do a simple conversion of special characters to their encoding.
|
static void |
ensureAttributes(org.w3c.dom.Node element,
java.lang.String[] attrs)
Make sure that the given element contains the given attributes.
|
static org.w3c.dom.NodeList |
eval(java.lang.String xmlFile,
java.lang.String xPath)
_more_
|
static javax.xml.xpath.XPathExpression |
expr(java.lang.String xPath)
_more_
|
static org.w3c.dom.Element |
findAncestor(org.w3c.dom.Element child,
java.lang.String tagName)
Find the ancestor of the given node with the given tagname
|
static org.w3c.dom.Element |
findChild(org.w3c.dom.Node parent,
java.lang.String tag)
Find the first child element of the given parent Node
whose tag name.equals the given tag.
|
static org.w3c.dom.Element |
findChildRecurseUp(org.w3c.dom.Node parent,
java.lang.String tag)
Find the first child element of the given parent Node
whose tag name.equals the given tag.
|
static java.util.List |
findChildren(org.w3c.dom.Node parent,
java.lang.String tag)
Find all of the children elements of the given parent Node
whose tag name.equals the given tag.
|
static java.util.List |
findChildrenRecurseUp(org.w3c.dom.Node parent,
java.lang.String tag)
Find all of the children elements of the given parent Node
and all of its ancestors whose tag name.equals the given tag.
|
static org.w3c.dom.Element |
findDescendant(org.w3c.dom.Node parent,
java.lang.String tag)
Find the first descendant element of the given parent Node
whose tag name.equals the given tag.
|
static org.w3c.dom.Element |
findDescendantFromPath(org.w3c.dom.Element parent,
java.lang.String path)
This method searches, starting at the given parent,
for a descendant path.
|
static java.util.List |
findDescendants(org.w3c.dom.Node parent,
java.lang.String tag)
Find all of the descendant elements of the given parent Node
whose tag name.equals the given tag.
|
static java.util.List |
findDescendantsFromPath(org.w3c.dom.Element parent,
java.lang.String path)
Like findDescendantFromPath, this method finds all descendants.
|
static org.w3c.dom.Element |
findElement(org.w3c.dom.Element root,
java.lang.String tag,
java.lang.String attributeName,
java.lang.String attributeValue)
Find the Element under (recursively) the given root Element
with the given tag name (if non-null) that contains
an attribute of the given name and value.
|
static org.w3c.dom.Element |
findElement(org.w3c.dom.NodeList elements,
java.lang.String attributeName,
java.lang.String attributeValue)
Find the first Element in the given NodeList of Elements
that has the given attribute with value .equals the
given attributeValue.
|
static org.w3c.dom.Element |
findRoot(org.w3c.dom.Element child)
Find the root element of the given node.
|
static org.w3c.dom.Element |
findUrlRefNode(org.w3c.dom.Element node)
This method will return either the given node argument
if it does not contain an attribute of name "url".
|
static org.w3c.dom.Element |
findUrlRefNode(org.w3c.dom.Element node,
java.lang.String urlAttr)
This method will return either the given node argument
if it does not contain an attribute of the given urlAttr.
|
static java.lang.String |
getAttribute(org.w3c.dom.NamedNodeMap attrs,
java.lang.String name)
Get the given name-d attribute from the given attrs map.
|
static boolean |
getAttribute(org.w3c.dom.NamedNodeMap attrs,
java.lang.String name,
boolean dflt)
Get the given name-d attribute from the given attrs map.
|
static java.awt.Color |
getAttribute(org.w3c.dom.NamedNodeMap attrs,
java.lang.String name,
java.awt.Color dflt)
Get the given name-d attribute from the given attrs map.
|
static double |
getAttribute(org.w3c.dom.NamedNodeMap attrs,
java.lang.String name,
double dflt)
Get the given name-d attribute from the given attrs map.
|
static float |
getAttribute(org.w3c.dom.NamedNodeMap attrs,
java.lang.String name,
float dflt)
Get the given name-d attribute from the given attrs map.
|
static int |
getAttribute(org.w3c.dom.NamedNodeMap attrs,
java.lang.String name,
int dflt)
Get the given name-d attribute from the given attrs map.
|
static java.lang.String |
getAttribute(org.w3c.dom.NamedNodeMap attrs,
java.lang.String name,
java.lang.String dflt)
Get the given name-d attribute from the given attrs map.
|
static java.lang.String |
getAttribute(org.w3c.dom.Node element,
java.lang.String name)
Get the given name attribute from the given element.
|
static boolean |
getAttribute(org.w3c.dom.Node element,
java.lang.String name,
boolean dflt)
Get the given name-d attribute from the given element.
|
static java.awt.Color |
getAttribute(org.w3c.dom.Node element,
java.lang.String name,
java.awt.Color dflt)
Get the given name-d attribute from the given element.
|
static double |
getAttribute(org.w3c.dom.Node element,
java.lang.String name,
double dflt)
Get the given name-d attribute from the given element.
|
static float |
getAttribute(org.w3c.dom.Node element,
java.lang.String name,
float dflt)
Get the given name-d attribute from the given element.
|
static int |
getAttribute(org.w3c.dom.Node element,
java.lang.String name,
int dflt)
Get the given name-d attribute from the given element.
|
static java.lang.String |
getAttribute(org.w3c.dom.Node element,
java.lang.String name,
java.lang.String dflt)
Get the given name-d attribute from the given element.
|
static java.lang.String |
getAttributeFromTree(org.w3c.dom.Node element,
java.lang.String name)
Get the given named attribute from the given element.
|
static boolean |
getAttributeFromTree(org.w3c.dom.Node element,
java.lang.String name,
boolean dflt)
_more_
|
static int |
getAttributeFromTree(org.w3c.dom.Node element,
java.lang.String name,
int dflt)
Get the given named attribute from the given element.
|
static java.lang.String |
getAttributeFromTree(org.w3c.dom.Node element,
java.lang.String name,
java.lang.String dflt)
Get the given named attribute from the given element.
|
static java.util.List |
getAttributesFromTree(org.w3c.dom.Node element,
java.lang.String name,
java.util.Hashtable tags)
Get a list of attributes of the given name from the given element
and all of its parent elements.
|
static java.util.List |
getAttributesFromTree(org.w3c.dom.Node element,
java.lang.String name,
java.util.Hashtable tags,
java.util.List listOfValues)
Get a list of attributes of the given name from the given element
and all of its parent elements.
|
static java.lang.String |
getCdata(java.lang.String s)
_more_
|
static java.lang.String |
getChildText(org.w3c.dom.Node parent)
Concatenates the node values (grom getNodeValue) of the children of the given parent Node.
|
static org.w3c.dom.Document |
getDocument(java.io.InputStream stream)
Create a Document object with the given xml.
|
static org.w3c.dom.Document |
getDocument(java.lang.String xml)
Create a Document object with the given xml.
|
static org.w3c.dom.Document |
getDocument(java.lang.String filename,
java.lang.Class originClass)
Read in the xml contained in the given filename, parse it and return the
root Element.
|
static org.w3c.dom.Element |
getElement(org.w3c.dom.Element parent,
java.lang.String tagName)
Get the first Element children of the given parent Element with the given tagName.
|
static org.w3c.dom.NodeList |
getElements(org.w3c.dom.Element parent)
Get all children of the given parent Element who are instances of
the Element class.
|
static XmlNodeList |
getElements(org.w3c.dom.Element parent,
java.lang.String tagName)
Get all Element children of the given parent Element with the
given tagName.
|
static org.w3c.dom.NodeList |
getElements(org.w3c.dom.Element parent,
XmlNodeList nodeList)
Get all children of the given parent Element who are instances of
the Element class.
|
static org.w3c.dom.Element |
getFirstChild(org.w3c.dom.Element parent)
Get the first Element child of the given parent Element.
|
static org.w3c.dom.NodeList |
getGrandChildren(org.w3c.dom.Element parent)
Get all grand children of the given parent Element who are instances of
the Element class.
|
static java.lang.String |
getGrandChildText(org.w3c.dom.Node parent,
java.lang.String childTag)
Finds the child node with the given tag name.
|
static java.lang.String |
getGrandChildText(org.w3c.dom.Node parent,
java.lang.String childTag,
java.lang.String dflt)
Finds the child node with the given tag name.
|
static double |
getGrandChildValue(org.w3c.dom.Node parent,
java.lang.String childTag,
double dflt)
_more_
|
static java.lang.String |
getHeader()
Return the default xml header.
|
static java.util.List |
getListOfElements(org.w3c.dom.Element parent)
Create and return a List of the Element children of the given parent node.
|
static java.lang.String |
getLocalName(org.w3c.dom.Node element)
Get the non qualified tag name
|
static java.lang.String |
getNodeName(org.w3c.dom.Node node)
Get the non qualified tag name
|
static org.w3c.dom.Element |
getRoot(java.io.InputStream stream)
Read in the xml contained in the given filename, parse it and return the
root Element.
|
static org.w3c.dom.Element |
getRoot(java.lang.String xml)
Parse the given xml and return the root Element.
|
static org.w3c.dom.Element |
getRoot(java.lang.String filename,
java.lang.Class originClass)
Read in the xml contained in the given filename, parse it and return the
root Element.
|
static boolean |
hasAttribute(org.w3c.dom.Node element,
java.lang.String attributeName)
Does the given node have the attribute
|
static boolean |
isFullyQualified(java.lang.String tagName)
_more_
|
static boolean |
isTag(org.w3c.dom.Node node,
java.lang.String name)
Checks if the tag name of the given node matches the given name.
|
static org.w3c.dom.Document |
loadXml(java.lang.String xmlFile)
_more_
|
static void |
main(java.lang.String[] args)
A main for tests
|
static org.w3c.dom.CDATASection |
makeCDataNode(org.w3c.dom.Document doc,
java.lang.String text)
_more_
|
static org.w3c.dom.CDATASection |
makeCDataNode(org.w3c.dom.Document doc,
java.lang.String text,
boolean andEncode)
_more_
|
static org.w3c.dom.Document |
makeDocument()
A utility to make an empty document
|
static void |
mergeAttributes(org.w3c.dom.Element n1,
org.w3c.dom.Element n2)
Copy the attributes from n2 to n1.
|
static java.lang.String |
openTag(java.lang.String name)
Make an open tag
|
static java.lang.String |
openTag(java.lang.String name,
java.lang.String attrs)
Return a String of the form: <name attrs />
|
static java.lang.String |
quote(java.lang.String value)
Wrap the given string value in quotes.
|
static void |
removeChildren(org.w3c.dom.Element parent)
Remove all children from the given parent Element.
|
static void |
setAttribute(org.w3c.dom.Element node,
java.lang.String name,
java.awt.Color value)
A utility to set the attribute on the given node as the
String representation of the given color
|
static void |
setAttributes(org.w3c.dom.Element node,
java.lang.String[] attrs)
The attrs parameter is an array of [name1, value1, name2, value2, etc].
|
static java.lang.String |
tag(java.lang.String name,
java.lang.String attrs)
Return a String of the form: <name attrs />
|
static java.lang.String |
tag(java.lang.String name,
java.lang.String attrs,
java.lang.String contents)
Return a String of the form: <name attrs > contents </name>
|
static void |
toHtml(java.lang.StringBuffer html,
org.w3c.dom.Node node)
_more_
|
static java.lang.String |
toString(org.w3c.dom.Node node)
Convert the DOM rooted at the given Node to an xml String representation.
|
static void |
toString(org.w3c.dom.Node node,
java.lang.Appendable appendable)
_more_
|
static java.lang.String |
toString(org.w3c.dom.Node node,
boolean prettyPrint)
Convert the DOM rooted at the given Node to an xml String representation.
|
static java.lang.String |
toString(org.w3c.dom.Node node,
java.lang.String tabSpacing,
java.lang.String newLine)
Convert the DOM rooted at the given Node to an xml representation.
|
static java.lang.String |
toString(org.w3c.dom.Node node,
java.lang.String tabSpacing,
java.lang.String newLine,
boolean recurse)
Convert the DOM rooted at the given Node to an xml representation.
|
static java.lang.String |
toStringNoChildren(org.w3c.dom.Node node)
Convert the DOM rooted at the given Node to an xml String representation.
|
static java.lang.String |
toStringWithHeader(org.w3c.dom.Node node)
Convert the DOM rooted at the given Node to an xml String representation.
|
static java.lang.String |
toStringWithHeader(org.w3c.dom.Node node,
java.lang.String tabSpacing,
java.lang.String newLine)
Convert the DOM rooted at the given Node to an xml representation.
|
static java.lang.String |
toStringWithHeader(org.w3c.dom.Node node,
java.lang.String tabSpacing,
java.lang.String newLine,
boolean prettifyAttrs)
Convert the xml to a string.
|
public static final java.lang.String XML_HEADER
public static final java.lang.String TAG_WILDCARD
public static final java.lang.String NULL_STRING
public static java.lang.String quote(java.lang.String value)
value
- the String to wrap in quotes.public static java.lang.String encodeBase64(byte[] b)
b
- The bytes to encodepublic static byte[] decodeBase64(java.lang.String s)
s
- Holds the base64 encoded bytespublic static java.lang.String comment(java.lang.String value)
value
- The String to comment.public static void attr(java.lang.Appendable buff, java.lang.String name, java.lang.String value, java.lang.String tab)
buff
- The string buffer to append onto.name
- The attribute name.value
- The attribute value.tab
- The tab to prepend onto the result.public static java.lang.String attr(java.lang.String name, java.lang.String value)
name
- The attribute name.value
- The attribute value.public static java.lang.String attrs(java.lang.String[] attrs)
attrs
- _more_public static java.lang.String attrs(java.lang.String name, java.lang.String value)
name
- _more_value
- _more_public static java.lang.String attrs(java.lang.String n1, java.lang.String v1, java.lang.String n2, java.lang.String v2)
n1
- The first attribute name.v1
- The first attribute value.n2
- The second attribute name.v2
- The second attribute value.public static java.lang.String attrs(java.lang.String n1, java.lang.String v1, java.lang.String n2, java.lang.String v2, java.lang.String n3, java.lang.String v3)
n1
- The first attribute name.v1
- The first attribute value.n2
- The second attribute name.v2
- The second attribute value.n3
- The third attribute name.v3
- The third attribute value.public static java.lang.String attrs(java.lang.String n1, java.lang.String v1, java.lang.String n2, java.lang.String v2, java.lang.String n3, java.lang.String v3, java.lang.String n4, java.lang.String v4)
n1
- The first attribute name.v1
- The first attribute value.n2
- The second attribute name.v2
- The second attribute value.n3
- The third attribute name.v3
- The third attribute value.n4
- The fourth attribute name.v4
- The fourth attribute value.public static java.lang.String tag(java.lang.String name, java.lang.String attrs, java.lang.String contents)
name
- The tag name.attrs
- The attribute section of the tag.contents
- The body of the tagpublic static java.lang.String tag(java.lang.String name, java.lang.String attrs)
name
- The tag name.attrs
- The attribute section of the tag.public static java.lang.String openTag(java.lang.String name, java.lang.String attrs)
name
- The tag name.attrs
- The attribute section of the tag.public static java.lang.String openTag(java.lang.String name)
name
- tag namepublic static java.lang.String closeTag(java.lang.String name)
name
- tag namepublic static java.lang.String getAttributeFromTree(org.w3c.dom.Node element, java.lang.String name)
element
- The xml node to look within.name
- The attribute namepublic static java.lang.String getAttributeFromTree(org.w3c.dom.Node element, java.lang.String name, java.lang.String dflt)
element
- The xml node to look within.name
- The attribute name.dflt
- The default value returned.public static int getAttributeFromTree(org.w3c.dom.Node element, java.lang.String name, int dflt)
element
- The xml node to look within.name
- The attribute name.dflt
- The default value returned.public static boolean getAttributeFromTree(org.w3c.dom.Node element, java.lang.String name, boolean dflt)
element
- _more_name
- _more_dflt
- _more_public static java.util.List getAttributesFromTree(org.w3c.dom.Node element, java.lang.String name, java.util.Hashtable tags)
element
- The xml node to look within.name
- The attribute name.tags
- If non-null then only look at elements whose tag name is held by the tags hashtable.
If the element we are looking at is not within the table then stop searching upwards.public static java.util.List getAttributesFromTree(org.w3c.dom.Node element, java.lang.String name, java.util.Hashtable tags, java.util.List listOfValues)
element
- The xml node to look within.name
- The attribute name.tags
- If non-null then only look at elements whose tag name is held by the tags hashtable.
If the element we are looking at is not within the table then stop searching upwards.listOfValues
- The list ot put the values in.public static boolean hasAttribute(org.w3c.dom.Node element, java.lang.String attributeName)
element
- nodeattributeName
- attributepublic static java.lang.String getAttribute(org.w3c.dom.Node element, java.lang.String name)
element
- The xml element to look within.name
- The attribute name.public static void ensureAttributes(org.w3c.dom.Node element, java.lang.String[] attrs)
element
- The xml element to look within.attrs
- Array of attribute names.public static java.lang.String getAttribute(org.w3c.dom.Node element, java.lang.String name, java.lang.String dflt)
element
- The xml element to look within.name
- The attribute name.dflt
- The default value.public static boolean getAttribute(org.w3c.dom.Node element, java.lang.String name, boolean dflt)
element
- The xml element to look within.name
- The attribute name.dflt
- The default value.public static int getAttribute(org.w3c.dom.Node element, java.lang.String name, int dflt)
element
- The xml element to look within.name
- The attribute name.dflt
- The default value.public static float getAttribute(org.w3c.dom.Node element, java.lang.String name, float dflt)
element
- The xml element to look within.name
- The attribute name.dflt
- The default value.public static double getAttribute(org.w3c.dom.Node element, java.lang.String name, double dflt)
element
- The xml element to look within.name
- The attribute name.dflt
- The default value.public static java.awt.Color getAttribute(org.w3c.dom.Node element, java.lang.String name, java.awt.Color dflt)
element
- The xml element to look within.name
- The attribute name.dflt
- The default value.public static java.lang.String getAttribute(org.w3c.dom.NamedNodeMap attrs, java.lang.String name)
attrs
- The xml attribute map.name
- The name of the attribute.public static java.lang.String getAttribute(org.w3c.dom.NamedNodeMap attrs, java.lang.String name, java.lang.String dflt)
attrs
- The xml attribute map.name
- The name of the attribute.dflt
- The default valuepublic static int getAttribute(org.w3c.dom.NamedNodeMap attrs, java.lang.String name, int dflt)
attrs
- The xml attribute map.name
- The name of the attribute.dflt
- The default valuepublic static float getAttribute(org.w3c.dom.NamedNodeMap attrs, java.lang.String name, float dflt)
attrs
- The xml attribute map.name
- The name of the attribute.dflt
- The default valuepublic static double getAttribute(org.w3c.dom.NamedNodeMap attrs, java.lang.String name, double dflt)
attrs
- The xml attribute map.name
- The name of the attribute.dflt
- The default valuepublic static boolean getAttribute(org.w3c.dom.NamedNodeMap attrs, java.lang.String name, boolean dflt)
attrs
- The xml attribute map.name
- The name of the attribute.dflt
- The default valuepublic static java.awt.Color getAttribute(org.w3c.dom.NamedNodeMap attrs, java.lang.String name, java.awt.Color dflt)
GuiUtils.decodeColor(java.lang.String, java.awt.Color)
).
If not found then return the dflt argument.attrs
- The xml attribute map.name
- The name of the attribute.dflt
- The default valuepublic static void setAttribute(org.w3c.dom.Element node, java.lang.String name, java.awt.Color value)
node
- The nodename
- The attr namevalue
- The colorpublic static void mergeAttributes(org.w3c.dom.Element n1, org.w3c.dom.Element n2)
n1
- The source of the attributes.n2
- What to copy into.public static void setAttributes(org.w3c.dom.Element node, java.lang.String[] attrs)
node
- The xml element to set attributes on.attrs
- The array of attribute name/value pairs.public static org.w3c.dom.Element findChild(org.w3c.dom.Node parent, java.lang.String tag)
parent
- The xml node to search for children.tag
- The tag name of the child xml element.public static java.util.List findChildrenRecurseUp(org.w3c.dom.Node parent, java.lang.String tag)
parent
- The xml node to search for children.tag
- The tag name of the child xml element.public static org.w3c.dom.Element findChildRecurseUp(org.w3c.dom.Node parent, java.lang.String tag)
parent
- The xml node to search for children.tag
- The tag name of the child xml element.public static java.util.List findChildren(org.w3c.dom.Node parent, java.lang.String tag)
parent
- The xml node to search for children.tag
- The tag name of the child xml element.public static void addChildren(org.w3c.dom.Element element, java.util.List children)
element
- The parent element.children
- The list of children.public static org.w3c.dom.Element findDescendant(org.w3c.dom.Node parent, java.lang.String tag)
parent
- The root of the xml dom tree to search.tag
- The tag name to match.public static java.util.List findDescendants(org.w3c.dom.Node parent, java.lang.String tag)
parent
- The root of the xml dom tree to search.tag
- The tag name to match.public static org.w3c.dom.Element findDescendantFromPath(org.w3c.dom.Element parent, java.lang.String path)
So, given:
path=Alabama.Alaska.Arkansasthis method will try to find the Arkansas tag which is a child of Alaska, which is a child of Alabama, which is a child of the given parent parameter.
parent
- The root of the xml dom tree to search.path
- The "." delimited string of tag names.public static java.util.List findDescendantsFromPath(org.w3c.dom.Element parent, java.lang.String path)
parent
- The root of the xml dom tree to search.path
- The "." delimited string of tag names.public static org.w3c.dom.Element getRoot(java.lang.String xml) throws java.lang.Exception
xml
- The xml.java.lang.Exception
- When something goes wrong.public static org.w3c.dom.Element create(java.lang.String tag, org.w3c.dom.Element parent) throws java.lang.Exception
tag
- _more_parent
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(java.lang.String tag, org.w3c.dom.Element parent, java.util.List attrs) throws java.lang.Exception
tag
- _more_parent
- _more_attrs
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(org.w3c.dom.Document doc, java.lang.String tag) throws java.lang.Exception
doc
- _more_tag
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(org.w3c.dom.Document doc, java.lang.String tag, org.w3c.dom.Element parent) throws java.lang.Exception
doc
- _more_tag
- _more_parent
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(org.w3c.dom.Document doc, java.lang.String tag, org.w3c.dom.Element parent, java.util.List attrs) throws java.lang.Exception
doc
- _more_tag
- _more_parent
- _more_attrs
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(org.w3c.dom.Document doc, java.lang.String tag, java.lang.String[] attrs) throws java.lang.Exception
doc
- _more_tag
- _more_attrs
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(org.w3c.dom.Document doc, java.lang.String tag, org.w3c.dom.Element parent, java.lang.String[] attrs) throws java.lang.Exception
doc
- _more_tag
- _more_parent
- _more_attrs
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(org.w3c.dom.Document doc, java.lang.String tag, org.w3c.dom.Element parent, java.lang.String text, java.lang.String[] attrs) throws java.lang.Exception
doc
- _more_tag
- _more_parent
- _more_text
- _more_attrs
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(org.w3c.dom.Document doc, java.lang.String tag, org.w3c.dom.Element parent, java.lang.String text) throws java.lang.Exception
doc
- _more_tag
- _more_parent
- _more_text
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(java.lang.String tag, org.w3c.dom.Element parent, java.lang.String[] attrs) throws java.lang.Exception
tag
- _more_parent
- _more_attrs
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(java.lang.String tag, org.w3c.dom.Element parent, java.lang.String text, java.lang.String[] attrs) throws java.lang.Exception
tag
- _more_parent
- _more_text
- _more_attrs
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element create(java.lang.String tag, org.w3c.dom.Element parent, java.lang.String text) throws java.lang.Exception
tag
- _more_parent
- _more_text
- _more_java.lang.Exception
- _more_public static org.w3c.dom.Element getRoot(java.lang.String filename, java.lang.Class originClass) throws java.lang.Exception
filename
- The filename, url or resource path of the xml document.originClass
- Where to look for resources.java.lang.Exception
- When something goes wrong.public static org.w3c.dom.Element getRoot(java.io.InputStream stream) throws java.lang.Exception
stream
- _more_java.lang.Exception
- When something goes wrong.public static org.w3c.dom.Document getDocument(java.lang.String filename, java.lang.Class originClass) throws java.lang.Exception
filename
- The filename, url or resource path of the xml document.originClass
- Where to look for resources.java.lang.Exception
- When something goes wrong.public static org.w3c.dom.Element findRoot(org.w3c.dom.Element child)
child
- The xml element to serach for the root of.public static boolean isTag(org.w3c.dom.Node node, java.lang.String name)
node
- the xml nodename
- namepublic static java.lang.String getLocalName(org.w3c.dom.Node element)
element
- elementpublic static boolean isFullyQualified(java.lang.String tagName)
tagName
- _more_public static java.lang.String getNodeName(org.w3c.dom.Node node)
node
- nodepublic static org.w3c.dom.Element findAncestor(org.w3c.dom.Element child, java.lang.String tagName)
child
- The xml element to serach for the root of.tagName
- The tag name to look forpublic static org.w3c.dom.Document makeDocument()
public static org.w3c.dom.Document getDocument(java.lang.String xml) throws java.lang.Exception
xml
- The xml.java.lang.Exception
- When something goes wrong.public static org.w3c.dom.Document getDocument(java.io.InputStream stream) throws java.lang.Exception
stream
- streamjava.lang.Exception
- When something goes wrong.public static org.w3c.dom.Element getFirstChild(org.w3c.dom.Element parent)
parent
- The xml node to search its chidlren.public static org.w3c.dom.NodeList getElements(org.w3c.dom.Element parent)
parent
- The xml node to search its chidlren.public static org.w3c.dom.NodeList getElements(org.w3c.dom.Element parent, XmlNodeList nodeList)
parent
- The xml node to search its chidlren.nodeList
- list to add topublic static org.w3c.dom.NodeList getGrandChildren(org.w3c.dom.Element parent)
parent
- The xml node to search its chidlren.public static java.lang.String getGrandChildText(org.w3c.dom.Node parent, java.lang.String childTag, java.lang.String dflt)
parent
- The xml node to search its chidlren.childTag
- _more_dflt
- _more_public static double getGrandChildValue(org.w3c.dom.Node parent, java.lang.String childTag, double dflt)
parent
- _more_childTag
- _more_dflt
- _more_public static java.lang.String getGrandChildText(org.w3c.dom.Node parent, java.lang.String childTag)
parent
- The xml node to search its chidlren.childTag
- _more_public static void appendCdataBytes(java.lang.StringBuffer sb, byte[] bytes)
sb
- _more_bytes
- _more_public static void appendCdata(java.lang.StringBuffer sb, java.lang.String s)
sb
- _more_s
- _more_public static java.lang.String getCdata(java.lang.String s)
s
- _more_public static org.w3c.dom.CDATASection makeCDataNode(org.w3c.dom.Document doc, java.lang.String text)
doc
- _more_text
- _more_public static void createCDataNode(org.w3c.dom.Element parent, java.lang.String text)
parent
- _more_text
- _more_public static org.w3c.dom.CDATASection makeCDataNode(org.w3c.dom.Document doc, java.lang.String text, boolean andEncode)
doc
- _more_text
- _more_andEncode
- _more_public static java.lang.String getChildText(org.w3c.dom.Node parent)
parent
- The xml node to search its chidlren.public static XmlNodeList getElements(org.w3c.dom.Element parent, java.lang.String tagName)
parent
- The xml node to search its children.tagName
- The tag to match.public static org.w3c.dom.Element getElement(org.w3c.dom.Element parent, java.lang.String tagName)
parent
- The xml node to search its children.tagName
- The tag to match.public static java.util.List getListOfElements(org.w3c.dom.Element parent)
parent
- The xml node to find its children.public static java.lang.String getHeader()
public static java.lang.String toString(org.w3c.dom.Node node)
node
- The xml node to convert its tree.public static java.lang.String toStringNoChildren(org.w3c.dom.Node node)
node
- The xml node to convert its tree.public static java.lang.String toStringWithHeader(org.w3c.dom.Node node)
node
- The xml node to convert its tree.public static java.lang.String toString(org.w3c.dom.Node node, boolean prettyPrint)
node
- The xml node to convert its tree.prettyPrint
- Should the string be formatted with
tabs and new linespublic static java.lang.String toString(org.w3c.dom.Node node, java.lang.String tabSpacing, java.lang.String newLine)
node
- The xml tree root.tabSpacing
- The spacing to put into the result string before each tag.newLine
- The new line to output after each tag.public static java.lang.String toString(org.w3c.dom.Node node, java.lang.String tabSpacing, java.lang.String newLine, boolean recurse)
node
- The xml tree root.tabSpacing
- The spacing to put into the result string before each tag.newLine
- The new line to output after each tag.recurse
- _more_public static java.lang.String toStringWithHeader(org.w3c.dom.Node node, java.lang.String tabSpacing, java.lang.String newLine)
node
- The xml tree root.tabSpacing
- The spacing to put into the result string before each tag.newLine
- The new line to output after each tag.public static void toString(org.w3c.dom.Node node, java.lang.Appendable appendable)
node
- _more_appendable
- _more_public static java.lang.String toStringWithHeader(org.w3c.dom.Node node, java.lang.String tabSpacing, java.lang.String newLine, boolean prettifyAttrs)
node
- xml roottabSpacing
- tabnewLine
- new lineprettifyAttrs
- If true then layout attributespublic static void toHtml(java.lang.StringBuffer html, org.w3c.dom.Node node)
html
- _more_node
- _more_public static java.lang.String encodeString(java.lang.String v)
v
- The source string.public static org.w3c.dom.Element findElement(org.w3c.dom.NodeList elements, java.lang.String attributeName, java.lang.String attributeValue)
elements
- The Elements to search.attributeName
- The attribute name to look for.attributeValue
- The value to match.public static org.w3c.dom.Element findElement(org.w3c.dom.Element root, java.lang.String tag, java.lang.String attributeName, java.lang.String attributeValue)
root
- The Element to seatrch under.tag
- The tag name of the descendant Element to match.attributeName
- The attribute name to look for.attributeValue
- The value to match.public static void removeChildren(org.w3c.dom.Element parent)
parent
- The xml element to remove children from.public static org.w3c.dom.Element findUrlRefNode(org.w3c.dom.Element node, java.lang.String urlAttr)
node
- The node to look at.urlAttr
- The attribute name that holds the url.public static org.w3c.dom.Element findUrlRefNode(org.w3c.dom.Element node)
node
- The node to look at.public static void main(java.lang.String[] args) throws java.lang.Exception
args
- Command line argumentsjava.lang.Exception
- _more_public static java.lang.String calculateRFC2104HMAC(java.lang.String data, java.lang.String key) throws java.security.SignatureException
data
- The data to be signed.key
- The signing key.java.security.SignatureException
- when signature generation failspublic static XmlUtil.ElementListIterator elements(java.lang.String xmlFile, java.lang.String xPath)
xmlFile
- _more_xPath
- _more_public static org.w3c.dom.NodeList eval(java.lang.String xmlFile, java.lang.String xPath)
xmlFile
- _more_xPath
- _more_public static org.w3c.dom.Document loadXml(java.lang.String xmlFile)
xmlFile
- _more_public static javax.xml.xpath.XPathExpression expr(java.lang.String xPath)
xPath
- _more_