|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.xbus.base.xml.XDomSupport
public abstract class XDomSupport
XDomSupport is a collection of operations on DOM trees. It
extends the possibilities offered in the org.w3c.dom package.
| Constructor Summary | |
|---|---|
XDomSupport()
|
|
| Method Summary | |
|---|---|
static void |
deleteWhitespaceTextInElementNodes(org.w3c.dom.Document doc)
deleteWhitespaceTextInElementNodes deletes all text nodes
containing only whitespace within xml tags. |
static void |
deleteWhitespaceTextInElementNodesAndComments(org.w3c.dom.Document doc)
deleteWhitespaceTextInElementNodesAndComments deletes all
text nodes containing only whitespace within xml tags and all comment
nodes. |
static java.util.List |
getChildElementsByValue(org.w3c.dom.Node parent,
java.lang.String value,
java.lang.String nodeTag)
getChildElementsByValue retrieves child nodes of type
element selected by a certain for the value stored with them. |
static java.util.List |
getChildNodesByAttrValue(org.w3c.dom.Node parent,
java.lang.String attrName,
java.lang.String attrValue,
java.lang.String nodeTag)
getChildNodesByAttrValue retrieves child nodes selected by
a certain value of a certain attribute. |
static int |
getNextNodeIndexIgnoringFormatingText(org.w3c.dom.NodeList nodes,
int startPos)
getNextNodeIndexIgnoringFormatingText retrieves the
position of the next node after the position startPos
within the list nodes which is not a text node only
containing whitespace. |
static java.lang.String |
getNodeText(org.w3c.dom.Node node)
|
static java.lang.String |
getTrimedNodeText(org.w3c.dom.Node node)
getTrimedNodeText retrieves the value for a node
representing the corresponding xml tag. |
static boolean |
isValidTagName(java.lang.String name)
isValidTagName checks if a string conforms to the
conventions for xml tag names. |
static java.lang.String |
makeTagNameValid(java.lang.String name)
Removes invalid characters from tag names. |
static void |
recursivePostOrder(org.w3c.dom.Node node,
IteratedNodeOperation itop)
recursivePostOrder is the recursive heart of DOM tree
pre-order traversal. |
static void |
traversePostOrder(org.w3c.dom.Document doc,
IteratedNodeOperation itop)
traversePostOrder traverses a DOM tree in post-order and
executes the specified operation on each node. |
static void |
traversePreOrder(org.w3c.dom.Document doc,
IteratedNodeOperation itop)
traversePreOrder traverses a DOM tree in pre-order and
executes the specified operation on each node. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XDomSupport()
| Method Detail |
|---|
public static java.util.List getChildNodesByAttrValue(org.w3c.dom.Node parent,
java.lang.String attrName,
java.lang.String attrValue,
java.lang.String nodeTag)
throws java.lang.IllegalArgumentException
getChildNodesByAttrValue retrieves child nodes selected by
a certain value of a certain attribute. Child nodes without the specified
attribute are not selected.
parent - the node for which children are searchedattrName - the attribute to checkattrValue - the attribute's value to search fornodeTag - the tag name for the searched child nodes, if
null or empty string the tag name is not used
for the selection
java.lang.IllegalArgumentException - in case that parent,
attrName or attrValue are
null or attrName is emptypublic static java.lang.String getNodeText(org.w3c.dom.Node node)
public static java.lang.String getTrimedNodeText(org.w3c.dom.Node node)
getTrimedNodeText retrieves the value for a node
representing the corresponding xml tag.
node - the node representing the xml tag
public static java.util.List getChildElementsByValue(org.w3c.dom.Node parent,
java.lang.String value,
java.lang.String nodeTag)
throws java.lang.IllegalArgumentException
getChildElementsByValue retrieves child nodes of type
element selected by a certain for the value stored with them.
parent - the node for which children are searchedvalue - the value to search fornodeTag - the tag name for the searched child nodes, if
null or empty string the tag name is not used
for the selection
java.lang.IllegalArgumentException - in case that parent or
value are null
public static int getNextNodeIndexIgnoringFormatingText(org.w3c.dom.NodeList nodes,
int startPos)
getNextNodeIndexIgnoringFormatingText retrieves the
position of the next node after the position startPos
within the list nodes which is not a text node only
containing whitespace.
nodes - the node liststartPos - the position to start from
public static void deleteWhitespaceTextInElementNodes(org.w3c.dom.Document doc)
throws XException
deleteWhitespaceTextInElementNodes deletes all text nodes
containing only whitespace within xml tags. This operation is useful to
get rid of formatting information in a parsed xml file.
doc - the DOM tree to clean
XException - only for syntactical reasons (use of a generic
traversal method)
public static void deleteWhitespaceTextInElementNodesAndComments(org.w3c.dom.Document doc)
throws XException
deleteWhitespaceTextInElementNodesAndComments deletes all
text nodes containing only whitespace within xml tags and all comment
nodes. This operation is useful to get rid of formatting and editor
information in a parsed xml file.
doc - the DOM tree to clean
XException - only for syntactical reasons (use of a generic
traversal method)
public static void traversePreOrder(org.w3c.dom.Document doc,
IteratedNodeOperation itop)
throws XException
traversePreOrder traverses a DOM tree in pre-order and
executes the specified operation on each node. The traversal may treat
dynamically deleted nodes but no extensions.
doc - the DOM tree to traverseitop - the operation to execute
XException - in case that itop throws one
public static void traversePostOrder(org.w3c.dom.Document doc,
IteratedNodeOperation itop)
throws XException
traversePostOrder traverses a DOM tree in post-order and
executes the specified operation on each node. The traversal may treat
dynamically deleted nodes but no extensions.
doc - the DOM tree to traverseitop - the operation to execute
XException - in case that itop throws one
public static void recursivePostOrder(org.w3c.dom.Node node,
IteratedNodeOperation itop)
throws XException
recursivePostOrder is the recursive heart of DOM tree
pre-order traversal. It proceeds on all children of the specified node
and then executes the specified operation on the node itself. The
traversal may treat dynamically deleted nodes but no extensions.
node - the actual nodeitop - the operation to execute
XException - in case that itop throws onepublic static boolean isValidTagName(java.lang.String name)
isValidTagName checks if a string conforms to the
conventions for xml tag names.
name - the string to check
true if the string is a well-formed tag name,
otherwise falsepublic static java.lang.String makeTagNameValid(java.lang.String name)
name - the name of the tag
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||