|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.empire.xml.XMLUtil
public class XMLUtil
This class provides a collection of static helper functions for common XML tasks. The class cannot be instanciated since all. methods provided are declared static.
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
log
|
Method Summary | |
---|---|
static org.w3c.dom.Element |
addElement(org.w3c.dom.Element parent,
java.lang.String name)
Adds a child element to the parent. |
static org.w3c.dom.Element |
addElement(org.w3c.dom.Node parent,
java.lang.String name,
java.lang.String value)
Adds a new child element to a parent. |
static org.w3c.dom.Element |
addElementNS(org.w3c.dom.Element parent,
java.lang.String prefix,
java.lang.String name)
|
static org.w3c.dom.Element |
addElementNS(org.w3c.dom.Node parent,
java.lang.String prefix,
java.lang.String name,
java.lang.String value)
Adds a new child element to a parent with a namespace. |
static boolean |
addNamespaceURIs(org.w3c.dom.Document doc,
java.util.Map<java.lang.String,java.lang.String> nsMap)
|
static boolean |
changeTagName(org.w3c.dom.Element elem,
java.lang.String newName)
Changes the tag name of an element. |
static org.w3c.dom.Document |
createDocument()
Returns a document newly created by the class's static DocumentBuilder. |
static org.w3c.dom.Element |
createDocument(java.lang.String rootElemName)
|
static org.w3c.dom.Element |
createDocumentNS(java.lang.String prefix,
java.lang.String rootElemName,
java.util.Map<java.lang.String,java.lang.String> nsMap)
|
static org.w3c.dom.Element |
findFirstChild(org.w3c.dom.Node parent,
java.lang.String tagName)
Finds the first (direct) child Element with a given tag name. |
static org.w3c.dom.Element |
findFirstChildDeep(org.w3c.dom.Document doc,
java.lang.String tagName)
Returns the first element which name matchtes a given tag name. |
static org.w3c.dom.Element |
findFirstChildDeep(org.w3c.dom.Element parent,
java.lang.String tagName)
Finds the first element which name matchtes a given tag name that is locacted anywhere below the given parent. |
static org.w3c.dom.Element |
findFirstChildWithAttrib(org.w3c.dom.Node parent,
java.lang.String tagName,
java.lang.String attrName,
java.lang.Object value)
Finds the first (direct) child element with a given tag name and attribute. |
static java.lang.String |
getChildText(org.w3c.dom.Node parent,
java.lang.String childName)
Returns the text value of a given child element. |
static javax.xml.parsers.DocumentBuilder |
getDocumentBuilder()
Returns an initialzed, namespace aware DocumentBuilder. |
static java.lang.String |
getElementText(org.w3c.dom.Node elem)
Retrieves the text of a given element. |
static org.w3c.dom.Element |
getFirstChild(org.w3c.dom.Node parent)
Gets the first (direct) child Element. |
static java.lang.String |
getNamespaceURI(org.w3c.dom.Document doc,
java.lang.String prefix)
|
static org.w3c.dom.Element |
getNextSiblingElement(org.w3c.dom.Element child,
boolean sameName)
Returns the next sibling Element for an element, optionally matching tag names. |
static org.w3c.dom.Element |
insertElement(org.w3c.dom.Node parent,
java.lang.String name,
org.w3c.dom.Element pos)
|
static org.w3c.dom.Element |
insertElement(org.w3c.dom.Node parent,
java.lang.String name,
java.lang.String value,
org.w3c.dom.Element pos)
Inserts a new child element to a parent. |
static org.w3c.dom.Element |
insertElementNS(org.w3c.dom.Node parent,
java.lang.String prefix,
java.lang.String name,
org.w3c.dom.Element pos)
|
static org.w3c.dom.Element |
insertElementNS(org.w3c.dom.Node parent,
java.lang.String prefix,
java.lang.String name,
java.lang.String value,
org.w3c.dom.Element pos)
Inserts a new child element to a parent. |
static boolean |
setElementText(org.w3c.dom.Node elem,
java.lang.Object text)
Sets the text value of an Element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
Method Detail |
---|
public static org.w3c.dom.Document createDocument()
public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
public static org.w3c.dom.Element createDocument(java.lang.String rootElemName)
public static org.w3c.dom.Element createDocumentNS(java.lang.String prefix, java.lang.String rootElemName, java.util.Map<java.lang.String,java.lang.String> nsMap)
public static boolean addNamespaceURIs(org.w3c.dom.Document doc, java.util.Map<java.lang.String,java.lang.String> nsMap)
public static java.lang.String getNamespaceURI(org.w3c.dom.Document doc, java.lang.String prefix)
public static org.w3c.dom.Element getFirstChild(org.w3c.dom.Node parent)
parent
- the parent element below which to search the child
public static org.w3c.dom.Element findFirstChild(org.w3c.dom.Node parent, java.lang.String tagName)
parent
- the parent element below which to search the childtagName
- the (tag) name of the desired child element
public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Element child, boolean sameName)
child
- the element from which to search for a next siblingsameName
- true to retrive the next sibling element of the same name, of false if any name is allowed
public static org.w3c.dom.Element findFirstChildWithAttrib(org.w3c.dom.Node parent, java.lang.String tagName, java.lang.String attrName, java.lang.Object value)
parent
- the parent element below which to search the childtagName
- the (tag) name of the desired child elementattrName
- the name of the attribute which value must match the given valuevalue
- the attribute value to which elements are matched.
public static org.w3c.dom.Element findFirstChildDeep(org.w3c.dom.Element parent, java.lang.String tagName)
parent
- the parent element below which to search the childtagName
- the (tag) name of the desired child element
public static org.w3c.dom.Element findFirstChildDeep(org.w3c.dom.Document doc, java.lang.String tagName)
doc
- the xml document in which to find an element of the given nametagName
- the (tag) name of the desired child element
public static java.lang.String getElementText(org.w3c.dom.Node elem)
elem
- the Element for which the text value is requested
public static boolean setElementText(org.w3c.dom.Node elem, java.lang.Object text)
elem
- the Element for which the text value should be settext
- the new text value of the element
public static org.w3c.dom.Element addElement(org.w3c.dom.Node parent, java.lang.String name, java.lang.String value)
parent
- the Element to which to append the childname
- the (tag) name of the new childvalue
- the text value of the new element. (can be null!)
public static org.w3c.dom.Element addElement(org.w3c.dom.Element parent, java.lang.String name)
parent
- name
-
public static org.w3c.dom.Element addElementNS(org.w3c.dom.Node parent, java.lang.String prefix, java.lang.String name, java.lang.String value)
parent
- the Element to which to append the childprefix
- the name of the namespace this element belongs toname
- the (tag) name of the new childvalue
- the text value of the new element. (can be null!)
public static org.w3c.dom.Element addElementNS(org.w3c.dom.Element parent, java.lang.String prefix, java.lang.String name)
public static org.w3c.dom.Element insertElement(org.w3c.dom.Node parent, java.lang.String name, java.lang.String value, org.w3c.dom.Element pos)
parent
- the Element to which to append the childname
- the (tag) name of the new childvalue
- the text value of the new element. (can be null!)pos
- the inserted element will be placed before this element
public static org.w3c.dom.Element insertElement(org.w3c.dom.Node parent, java.lang.String name, org.w3c.dom.Element pos)
public static org.w3c.dom.Element insertElementNS(org.w3c.dom.Node parent, java.lang.String prefix, java.lang.String name, java.lang.String value, org.w3c.dom.Element pos)
parent
- the Element to which to append the childprefix
- name
- the (tag) name of the new childvalue
- the text value of the new element. (can be null!)pos
- pos the inserted element will be placed before this element
public static org.w3c.dom.Element insertElementNS(org.w3c.dom.Node parent, java.lang.String prefix, java.lang.String name, org.w3c.dom.Element pos)
public static java.lang.String getChildText(org.w3c.dom.Node parent, java.lang.String childName)
parent
- the Element which contains the childchildName
- the (tag) name of the child
public static boolean changeTagName(org.w3c.dom.Element elem, java.lang.String newName)
elem
- Element which name should be changednewName
- new tag name of the element
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |