|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object se.lth.cs.nlp.nlputils.core.DOMUtils
public class DOMUtils
A utility class which contains static methods to simplify some chores common when working with DOM trees.
Method Summary | |
---|---|
static void |
cacheNode(Node fromNode,
String id,
Node toNode)
|
static Document |
createDocument(String docName,
String dtd)
Creates a new document. |
static byte[] |
documentToXMLBytes(Document document,
String encoding)
Converts the Document to a byte array, taking the declared XML character encoding into account. |
static Node |
findChildByName(Node n,
String childName)
Finds the first child node with a certain name if one exists. |
static Node |
findNodeById(Node node,
String id)
This is needed because Document.getElementById does not seems to work well in our DOM implementation. |
static Node |
firstChild(Node node)
Returns the first non-text child of the node. |
static Node |
lastChild(Node node)
Returns the last non-text child of the node. |
static Node |
nextSibling(Node node)
Returns the next non-text sibling of the node. |
static Node |
previousSibling(Node node)
Returns the previous non-text sibling of the node. |
static void |
printStats()
|
static Document |
readDocument(InputSource in)
Reads a document. |
static Document |
readDocument(InputStream in)
Reads a document. |
static void |
replaceChildByName(Node n,
String childName,
Node newChild,
String[] predecessors)
Replaces a child node. |
static String |
treeToString(Document document)
|
static String |
treeToString(Document document,
String charset)
Returns a string containing the XML printout of a document. |
static void |
validate(Document document)
Validates a document against its DTD. |
static void |
writeDocument(Document document,
OutputStream out)
|
static void |
writeDocument(Document document,
StreamResult out)
|
static Document |
XMLBytesToDocument(byte[] bytes)
Converts the byte array to a Document, taking the declared XML character encoding into account. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void replaceChildByName(Node n, String childName, Node newChild, String[] predecessors)
n
- The parent node.childName
- The node name of the child to replace.newChild
- The new child node.predecessors
- The names of those children which may appear before
the child to replace.public static Node findChildByName(Node n, String childName)
n
- The parent node.childName
- The name of the child node.
public static Document createDocument(String docName, String dtd)
public static Document readDocument(InputSource in)
public static Document readDocument(InputStream in)
public static void writeDocument(Document document, StreamResult out)
public static void writeDocument(Document document, OutputStream out)
public static String treeToString(Document document, String charset)
public static String treeToString(Document document)
public static Document XMLBytesToDocument(byte[] bytes)
public static byte[] documentToXMLBytes(Document document, String encoding)
public static Node findNodeById(Node node, String id)
public static void cacheNode(Node fromNode, String id, Node toNode)
public static void printStats()
public static void validate(Document document)
public static Node firstChild(Node node)
public static Node nextSibling(Node node)
public static Node lastChild(Node node)
public static Node previousSibling(Node node)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |