|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.novell.xml.dom.DOMUtil
Utility class implementing, among others, things we need for DOM that aren't defined by the 1.0 DOM spec (namespaces, for example)
| Method Summary | |
static boolean |
addNamespaceDecls(Node node)
Adds namespace declarations as needed to match DOM Level 2 namespace attributes. |
static boolean |
checkNamespacesAgree(Node node)
Check's whether or not namespace declarations match DOM Level 2 namespace attributes |
static Document |
cloneDocument(Document srcDoc)
Creates a clone of the input document. |
static int |
compareNodes(Node node1,
Node node2)
Compare first node with second node for equivalence and some semblance of order |
static int |
deepCompareNodes(Node node1,
Node node2)
Compare first node with second node and all of their children and attribute for equality and some semblance of order. |
static String |
describeNode(Node node)
Returns a brief description of the specified node, appropriate for error reporting and debugging. |
static Comparator |
getDeepNodeComparator()
get a Comparator that compares Node hierarchies |
static Element |
getElementByID(Document document,
String idValue)
Return the element in the passed document that has the passed ID. |
static ExpandedQName |
getExpandedName(Node node)
Return the expanded name for the node. |
static String |
getLocalName(Node node)
Returns the local name of the specified node. |
static NamespaceName |
getNamespaceName(Node node)
Returns the namespace name (the namespace URI) of the specified node. |
static Comparator |
getNodeComparator()
get a Comparator that compares Nodes |
static String |
getPrefixforNSURI(String namespaceURI,
Node node)
Return the prefix string (if any) given a namespace URI and a node as context. |
static StylesheetAssociation[] |
getStylesheetAssociations(Document document,
String baseURI)
Returns all stylesheet associations found in the passed document's prologue that are specified with the xml-stylesheet processing instruction.
|
static String |
getURIforNSPrefix(String prefix,
Node node)
Return the URI string given a prefix string and a node as context. |
static void |
printDocument(Writer writer,
Document document)
output a generic DOM document as XML |
static void |
printDocumentWithFormat(Writer writer,
Document document)
output a generic DOM document as XML with whitespace formatting |
static void |
printFragment(Writer writer,
Node fragment)
Output a DOM subtree, serialized as XML |
static int |
stringCompare(String str1,
String str2)
String order comparison that won't blow up if either or both of the strings are null a non-empty value |
static boolean |
stringsEqual(String str1,
String str2)
String equality comparison that won't blow up if either or both of the strings are null a non-empty value |
static void |
stripWhitespace(Node root)
Strip a DOM subtree of Text nodes that are pure whitespace, unless an ancestor
element has an xml:space attribute equal to "preserve" and no closer
ancestor element has an xml:space attribute equal to "default".
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static void printDocument(Writer writer,
Document document)
throws IOException
document - instance of DOM document to outputwriter - output stream
IOException
public static void printDocumentWithFormat(Writer writer,
Document document)
throws IOException
document - instance of DOM document to outputwriter - output stream
IOException
public static void printFragment(Writer writer,
Node fragment)
throws IOException
writer - The writer object to use as the serializer encoder.fragment - The root of the subtree to output
IOExceptionpublic static void stripWhitespace(Node root)
Text nodes that are pure whitespace, unless an ancestor
element has an xml:space attribute equal to "preserve" and no closer
ancestor element has an xml:space attribute equal to "default".
This operation will combine any adjacent text nodes in the subtree.
root - The root of the DOM subtree to strip.public static String describeNode(Node node)
node - the node to be described
public static ExpandedQName getExpandedName(Node node)
node - The node whose expanded name should be returned.
public static String getLocalName(Node node)
This method is needed because DOM Level 1 does not support namespaces.
node - the node whose local name is to be returned
public static NamespaceName getNamespaceName(Node node)
This method is needed because DOM Level 1 does not support namespaces.
node - the node whose namespace name is to be returned
null if the node
is not in a namespace
public static String getURIforNSPrefix(String prefix,
Node node)
prefix - The prefix string for which to find the URInode - The namespace context node.
public static String getPrefixforNSURI(String namespaceURI,
Node node)
namespaceURI - The URI for which to find the prefix stringnode - The namespace context node.
public static Element getElementByID(Document document,
String idValue)
document - The document in which to find the element.idValue - The id value.
public static StylesheetAssociation[] getStylesheetAssociations(Document document,
String baseURI)
xml-stylesheet processing instruction.
document - the document whose stylesheet URI is to be returnedbaseURI - The baseURI for the passed document (may be null)
xml-stylesheet
processing instruction. The length may be 0 if no xml-stylesheet processing instructions
are found in the document prologue. The order of the elements of the returned array corresponds
to the order of the xml-stylesheet processing instructions in the document prologue.
public static Document cloneDocument(Document srcDoc)
throws DOMException
srcDoc - the document to be cloned
DOMExceptionpublic static boolean checkNamespacesAgree(Node node)
node - root of subtree to check
public static boolean addNamespaceDecls(Node node)
node - root of subtree to process
public static boolean stringsEqual(String str1,
String str2)
str1 - string 1str2 - string 2
public static int stringCompare(String str1,
String str2)
str1 - string 1str2 - string 2
public static int compareNodes(Node node1,
Node node2)
node1 - first nodenode2 - second node
public static int deepCompareNodes(Node node1,
Node node2)
This is the same as DOM Level 3 Node.isEqualNode() except that it adds a stable sort order in addition to equality
node1 - first nodenode2 - second node
public static Comparator getNodeComparator()
public static Comparator getDeepNodeComparator()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||