unbbayes.util
Class XMLUtil

java.lang.Object
  extended by unbbayes.util.XMLUtil

public class XMLUtil
extends Object

This class is a XML utility class. It requires two Apache Java modules: -- Xerces (Java XML parsers) -- Xalan (XSLT stylesheet processors).

Author:
Copyright (c) 2001 by RDA Corporation, Inc. All Rights Reserved.

Method Summary
static Document createDocument()
          creates a new empty DOM document.
static Document getDocument(InputSource poInputSource)
          returns an XML DOM object.
static Document getDocument(String poStringInput)
          returns an XML DOM object.
static Element getElement(Document pDocument, String psTagName, int index)
          returns a XML element.
static NodeList getNodeList(Document pDocument, String psTagName)
          returns a XML node list.
static Node getNodeTree(Document poDocument, String xPath)
          Create a new node tree based on a node tree
static int getSize(Document pDocument, String psTagName)
          returns a XML node size.
static String getValue(Document pDocument, String psTagName)
          returns a XML node value.
static String getValue(Element pElement)
          returns a XML element value.
static String getValue(Node pNode)
          returns a XML node value.
static String getXML(Document pDocument)
          returns an XML string.
static String getXML(Node pNode)
          returns an XML string.
static void insertNode(Document poDocument, Node poNode, Node poNodeToInsert)
          Insert a node into the document.
static void insertNode(Document poDocument, Node poNode, Node poNodeToInsert, boolean pbFlag)
          Insert a node into the document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDocument

public static Document getDocument(String poStringInput)
                            throws Exception
returns an XML DOM object.

Parameters:
poStringInput - String XML string input
Returns:
Document XML DOM document
Throws:
Exception

getDocument

public static Document getDocument(InputSource poInputSource)
                            throws Exception
returns an XML DOM object.

Parameters:
poInputSource - InputSource XML string stream input
Returns:
Document XML DOM document
Throws:
Exception

getXML

public static String getXML(Document pDocument)
                     throws Exception
returns an XML string.

Parameters:
pDocument - Document XML DOM document
Returns:
String XML string
Throws:
Exception

getXML

public static String getXML(Node pNode)
returns an XML string.

Parameters:
pNode - Node XML Document node
Returns:
String XML string

getNodeList

public static NodeList getNodeList(Document pDocument,
                                   String psTagName)
returns a XML node list.

Parameters:
pDocument - Document XML DOM document
psTagName - String XML node name
Returns:
NodeList XML node list

getElement

public static Element getElement(Document pDocument,
                                 String psTagName,
                                 int index)
returns a XML element.

Parameters:
pDocument - Document XML DOM document
psTagName - String XML node name
index - int XML node position
Returns:
Element XML node element

getSize

public static int getSize(Document pDocument,
                          String psTagName)
returns a XML node size.

Parameters:
pDocument - Document XML DOM document
psTagName - String XML node name
Returns:
int XML node size

getValue

public static String getValue(Document pDocument,
                              String psTagName)
                       throws Exception
returns a XML node value.

Parameters:
pDocument - Document XML DOM document
psTagName - String XML node name
Returns:
String XML node value
Throws:
Exception

getValue

public static String getValue(Element pElement)
                       throws Exception
returns a XML element value.

Parameters:
pElement - Document XML element
Returns:
String XML node value
Throws:
Exception

getValue

public static String getValue(Node pNode)
                       throws Exception
returns a XML node value.

Parameters:
pNode - Document XML node
Returns:
String XML node value
Throws:
Exception

createDocument

public static Document createDocument()
creates a new empty DOM document.

Returns:
Document

getNodeTree

public static Node getNodeTree(Document poDocument,
                               String xPath)
Create a new node tree based on a node tree

Parameters:
poDocument - Source Document XML
xPath - the XPATH
Returns:
Node

insertNode

public static void insertNode(Document poDocument,
                              Node poNode,
                              Node poNodeToInsert,
                              boolean pbFlag)
Insert a node into the document.

Parameters:
poDocument - Source Document XML
poNode - Node where the new node is going to be inserted into
poNodeToInsert - Node to be inserted into
pbFlag - Flag to indicate if poNodeToInsert is created by document poDocument

insertNode

public static void insertNode(Document poDocument,
                              Node poNode,
                              Node poNodeToInsert)
Insert a node into the document.

Parameters:
poDocument - Source Document XML
poNode - Node where the new node is going to be inserted into
poNodeToInsert - Node to be inserted into


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.