jd.xml.util
Class DomUtil

java.lang.Object
  extended byjd.xml.util.DomUtil

public abstract class DomUtil
extends Object

A collection of utility functions to support DOM handling.


Constructor Summary
DomUtil()
           
 
Method Summary
static Node getFirstSibling(Node node)
          Return the first sibling of the given node.
static Attr getInheritedAttribute(Node node, String namespaceUri, String name)
          Return an attribute, that is declared for the given node or one of its ancestors.
static String getNamespaceUri(Node node, String prefix)
          Return the namespace uri for a given prefix.
static int getNodeLevel(Node node)
          Return the node level.
static Node getParentOrOwner(Node node)
          Return the parent of the node or the owner element (if it is an Attribute).
static boolean getPreserveXmlSpace(Node node)
          Test if the value of the inherited attribute xml:space equals "preserve".
static String getXmlBaseUri(Node node, String documentBaseUri)
          Return the value of the inherited attribute xml:base for the given node.
static String getXmlLanguage(Node node)
          Return the value of the inherited attribute xml:base for the given node.
static boolean isNamespaceNode(Node attribute)
          Test if an attribute is a namespace node.
static boolean isNamespaceNode(String name)
          Test if an attribute with the given name is a namespace node.
static void stripWhitespace(Document doc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomUtil

public DomUtil()
Method Detail

getParentOrOwner

public static Node getParentOrOwner(Node node)
Return the parent of the node or the owner element (if it is an Attribute).


getInheritedAttribute

public static Attr getInheritedAttribute(Node node,
                                         String namespaceUri,
                                         String name)
Return an attribute, that is declared for the given node or one of its ancestors.

Parameters:
node - the node
namespaceUri - the namespace uri of the attribute or null
name - the attribute name or local name if namespaceUri is not null
Returns:
the attribute or null if no one is defined.

getXmlBaseUri

public static String getXmlBaseUri(Node node,
                                   String documentBaseUri)
Return the value of the inherited attribute xml:base for the given node.

Returns:
the value or null if no xml:base attribute is defined.

getXmlLanguage

public static String getXmlLanguage(Node node)
Return the value of the inherited attribute xml:base for the given node.

Returns:
the value or null if no xml:base attribute is defined.

getPreserveXmlSpace

public static boolean getPreserveXmlSpace(Node node)
Test if the value of the inherited attribute xml:space equals "preserve".


getFirstSibling

public static Node getFirstSibling(Node node)
Return the first sibling of the given node.


getNodeLevel

public static int getNodeLevel(Node node)
Return the node level. The document node has level 0, its children level 1, etc.


isNamespaceNode

public static boolean isNamespaceNode(Node attribute)
Test if an attribute is a namespace node.


isNamespaceNode

public static boolean isNamespaceNode(String name)
Test if an attribute with the given name is a namespace node.


getNamespaceUri

public static String getNamespaceUri(Node node,
                                     String prefix)
Return the namespace uri for a given prefix.


stripWhitespace

public static void stripWhitespace(Document doc)