org.xiruss.util
Class DomUtil

java.lang.Object
  extended by org.xiruss.util.DomUtil

public class DomUtil
extends java.lang.Object


Field Summary
(package private) static org.apache.log4j.Logger logger
           
 
Constructor Summary
DomUtil()
           
 
Method Summary
static java.util.Collection getDocumentNamespaces(org.w3c.dom.Element elem)
          Given an element, returns the list of all unique namespace URIs used in the element tree rooted at that element.
static org.w3c.dom.Document getDomForByteArray(byte[] byteArray)
          Constructs a DOM from a byte array containing the bytes of an XML document.
static org.w3c.dom.Document getDomForDocument(java.io.File xmlFile)
          Constructs a DOM from the specified XML document file.
static org.w3c.dom.Document getDomForStorageObject(StorageObject so)
           
static org.w3c.dom.Document getDomForStream(java.io.InputStream stream)
          Constructs a DOM from the specified XML document file.
static org.w3c.dom.Document getDomForString(java.lang.String docString)
          Constructs a DOM from the specified XML document file.
static void getElementNamespaces(org.w3c.dom.Element element, java.util.Set namespaces)
          Gets the namespaces declared on the element and adds them to the specified set.
static java.lang.String getNamespacePrefix(org.w3c.dom.Element element, java.lang.String nsURI)
          Given an element node and a namespace URI, returns the local prefix associated with that namespace (that is, the nearest ancestor or self element that declares the namespace).
static void getSubtreeNamespaces(org.w3c.dom.Element elem, java.util.Set namespaces)
          Recursive method to get all the namespaces within a subtree of elements.
static java.lang.String UpdateSchemaLocationValue(java.lang.String originalAttVal, java.lang.String schemaUri, java.lang.String newSchemaLoc)
          Given a schemaLocation attribute value, replaces the URI for a given namespace with the specified new URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
Constructor Detail

DomUtil

public DomUtil()
Method Detail

getDomForDocument

public static org.w3c.dom.Document getDomForDocument(java.io.File xmlFile)
                                              throws DomException
Constructs a DOM from the specified XML document file.

Parameters:
xmlFile - Document entity of the file to load.
Returns:
The DOM Document object for the document.
Throws:
DomException

getDomForStream

public static org.w3c.dom.Document getDomForStream(java.io.InputStream stream)
                                            throws DomException
Constructs a DOM from the specified XML document file.

Parameters:
xmlFile - Document entity of the file to load.
Returns:
The DOM Document object for the document.
Throws:
DomException

getDomForByteArray

public static org.w3c.dom.Document getDomForByteArray(byte[] byteArray)
                                               throws DomException
Constructs a DOM from a byte array containing the bytes of an XML document.

Parameters:
byteArray - The bytes to process
Returns:
The DOM Document object for the document.
Throws:
DomException

getDomForString

public static org.w3c.dom.Document getDomForString(java.lang.String docString)
                                            throws DomException
Constructs a DOM from the specified XML document file.

Parameters:
xmlFile - Document entity of the file to load.
Returns:
The DOM Document object for the document.
Throws:
DomException

getDomForStorageObject

public static org.w3c.dom.Document getDomForStorageObject(StorageObject so)
                                                   throws DomException,
                                                          java.io.IOException
Parameters:
candDoc -
Returns:
Throws:
DomException
java.io.IOException

getNamespacePrefix

public static java.lang.String getNamespacePrefix(org.w3c.dom.Element element,
                                                  java.lang.String nsURI)
Given an element node and a namespace URI, returns the local prefix associated with that namespace (that is, the nearest ancestor or self element that declares the namespace).

Parameters:
element - The element to check.
nsURI - The URI of the namespace whose prefix you want.
Returns:
Returns the prefix or null if the namespace is not declared.

getDocumentNamespaces

public static java.util.Collection getDocumentNamespaces(org.w3c.dom.Element elem)
Given an element, returns the list of all unique namespace URIs used in the element tree rooted at that element.


getSubtreeNamespaces

public static void getSubtreeNamespaces(org.w3c.dom.Element elem,
                                        java.util.Set namespaces)
Recursive method to get all the namespaces within a subtree of elements.

Parameters:
elem -
namespaces -

getElementNamespaces

public static void getElementNamespaces(org.w3c.dom.Element element,
                                        java.util.Set namespaces)
Gets the namespaces declared on the element and adds them to the specified set.

Parameters:
element - The element to examine.
namespaces - A set to which new namespace URIs will be added.

UpdateSchemaLocationValue

public static java.lang.String UpdateSchemaLocationValue(java.lang.String originalAttVal,
                                                         java.lang.String schemaUri,
                                                         java.lang.String newSchemaLoc)
Given a schemaLocation attribute value, replaces the URI for a given namespace with the specified new URI.

Parameters:
string -
Returns: