| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.optimizationservices.oscommon.util.XMLUtil
public class XMLUtil
The XMLUtil class contains methods for performing
 common basic XML-related operations used by various classes in the
 Optimization Services (OS) framework. 
| Constructor Summary | |
|---|---|
XMLUtil()
 | 
|
| Method Summary | |
|---|---|
static java.util.GregorianCalendar | 
createNativeDateTime(java.lang.String xsDateTime)
Create the the native date/time from the standard xs:dateTime.  | 
static org.w3c.dom.Document | 
createNewDocument()
Obtain a new instance of a DOM Document object
 to build a DOM tree with. | 
static org.w3c.dom.Element | 
createOSxLRootElement(org.w3c.dom.Document document,
                      java.lang.String osxlName)
Create the basic OSxL root element.  | 
static java.lang.String | 
createXSDateTime(java.util.GregorianCalendar dateTime)
Create the standard xs:dateTime string from the native date/time  | 
static org.w3c.dom.Node | 
findChildNode(org.w3c.dom.Node parentNode,
              java.lang.String childNodeName)
Find a parent node's first child node by the child node's name.  | 
static java.lang.String | 
generateSaxParseExceptionInXML(java.lang.String exceptionType,
                               org.xml.sax.SAXParseException e)
Returns the SAX Exception in the following XML format:  | 
static java.util.Vector<org.w3c.dom.Element> | 
getChildElementsByTagName(org.w3c.dom.Node parentNode,
                          java.lang.String childNodeName)
Get a parent node's child elements by the child node's tag name.  | 
static java.lang.String | 
getElementValue(org.w3c.dom.Element element)
Get the value of an element in a string.  | 
static java.lang.String | 
getElementValueByName(org.w3c.dom.Element rootElement,
                      java.lang.String descendantName)
Get the text value of a descendant element by the element's name.  | 
static void | 
main(java.lang.String[] args)
main for test purposes.  | 
static org.w3c.dom.Document | 
parseFileUsingDOM(java.lang.String fileName,
                  boolean validate)
Parse the xml file that contains the xml instance using DOM.  | 
static boolean | 
parseFileUsingSAX(java.lang.String fileName,
                  org.xml.sax.helpers.DefaultHandler saxHandler,
                  boolean validate)
Parse the xml file that contains the xml instance using SAX.  | 
static org.w3c.dom.Document | 
parseStringUsingDOM(java.lang.String xmlString,
                    boolean validate)
Parse the xml string that contains the xml instance using DOM.  | 
static boolean | 
parseStringUsingSAX(java.lang.String xmlString,
                    org.xml.sax.helpers.DefaultHandler saxHandler,
                    boolean validate)
Parse the xml string that contains the xml instance using SAX.  | 
static int | 
removeAllAttributes(org.w3c.dom.Element element)
Remove all the attributes of an element.  | 
static int | 
removeAllChildren(org.w3c.dom.Node parentNode)
Remove all the child nodes of a parent node.  | 
static int | 
removeChildrenByName(org.w3c.dom.Node parentNode,
                     java.lang.String childName)
Remove all the child nodes of a parent node with a given name.  | 
static void | 
setElementValue(org.w3c.dom.Element element,
                java.lang.String value)
Set the value (i.e.  | 
static boolean | 
writeXMLDocumentToFile(org.w3c.dom.Document xmlDocument,
                       java.lang.String fileName)
Write an xml file from a DOM tree document to a file.  | 
static boolean | 
writeXMLDocumentToStandardOutput(org.w3c.dom.Document xmlDocument)
Write an xml file from a DOM tree document to the standard output (e.g.  | 
static java.lang.String | 
writeXMLDocumentToString(org.w3c.dom.Document xmlDocument)
Write an xml file from a DOM tree document to a string.  | 
static boolean | 
writeXMLElementToFile(org.w3c.dom.Element element,
                      java.lang.String fileName)
Write DOM tree element to a file.  | 
static boolean | 
writeXMLElementToStandardOutput(org.w3c.dom.Element element)
Write DOM tree element to the standard output (e.g.  | 
static java.lang.String | 
writeXMLElementToString(org.w3c.dom.Element element)
Write an xml file from a DOM tree document to a string.  | 
| Methods inherited from class java.lang.Object | 
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public XMLUtil()
| Method Detail | 
|---|
public static java.lang.String generateSaxParseExceptionInXML(java.lang.String exceptionType,
                                                              org.xml.sax.SAXParseException e)
<parse_exceptionType>
<file> ... </file>
<line>...</line>
<column>...</column>
<message>...</message>
</parse_exceptionType>.
exceptionType - e.g. "warning", "error", "fatalError".
public static boolean parseFileUsingSAX(java.lang.String fileName,
                                        org.xml.sax.helpers.DefaultHandler saxHandler,
                                        boolean validate)
fileName - holds the name of the file that contains the xml instancesaxHandler - is a user implementation of the core sax handlers.validate - holds whether the parser should be validating against the xml schema or not.
public static boolean parseStringUsingSAX(java.lang.String xmlString,
                                          org.xml.sax.helpers.DefaultHandler saxHandler,
                                          boolean validate)
xmlString - holds the xml string that contains the xml instancesaxHandler - is a user implementation of the core sax handlers.validate - holds whether the parser should be validating against the xml schema or not.
public static org.w3c.dom.Document parseFileUsingDOM(java.lang.String fileName,
                                                     boolean validate)
fileName - holds the name of the file that contains the xml instance.validate - holds whether the parser should be validating against the xml schema or not.
public static org.w3c.dom.Document parseStringUsingDOM(java.lang.String xmlString,
                                                       boolean validate)
xmlString - holds the xml string that contains the xml instance.validate - holds whether the parser should be validating against the xml schema or not.
public static org.w3c.dom.Document createNewDocument()
Document object
 to build a DOM tree with.  An alternative way to create a DOM
 Document object is to use the
 getDOMImplementation
 method to get a DOM Level 2 DOMImplementation object and then use
 DOM Level 2 methods on that object to create a DOM Document object.
public static boolean writeXMLDocumentToFile(org.w3c.dom.Document xmlDocument,
                                             java.lang.String fileName)
xmlDocument - holds the xml document to write out to a file.fileName - holds the xml filename to write out the file to.
public static boolean writeXMLDocumentToStandardOutput(org.w3c.dom.Document xmlDocument)
xmlDocument - holds the xml document to write out to the standard output.
public static java.lang.String writeXMLDocumentToString(org.w3c.dom.Document xmlDocument)
xmlDocument - holds the xml document to write out to the String.
public static boolean writeXMLElementToFile(org.w3c.dom.Element element,
                                            java.lang.String fileName)
element - holds the xml element to write out to a file.fileName - holds the xml filename to write out the file to.
public static boolean writeXMLElementToStandardOutput(org.w3c.dom.Element element)
element - holds the xml element to write out to the standard output.
public static java.lang.String writeXMLElementToString(org.w3c.dom.Element element)
element - holds the xml element to write out to the String.
public static org.w3c.dom.Node findChildNode(org.w3c.dom.Node parentNode,
                                             java.lang.String childNodeName)
parentNode - holds the parent node.childNodeName - holds the name of the child node to find.
public static java.util.Vector<org.w3c.dom.Element> getChildElementsByTagName(org.w3c.dom.Node parentNode,
                                                                              java.lang.String childNodeName)
parentNode - holds the parent node.childNodeName - holds the name of the children node to find.
public static int removeAllChildren(org.w3c.dom.Node parentNode)
parentNode - holds the node for which its child nodes are to be removed.
public static int removeAllAttributes(org.w3c.dom.Element element)
element - holds the element for which its attributes are to be removed.
public static int removeChildrenByName(org.w3c.dom.Node parentNode,
                                       java.lang.String childName)
parentNode - holds the node for which its child nodes are to be removed.childName - holds the name of the children to be removed.
public static java.lang.String getElementValueByName(org.w3c.dom.Element rootElement,
                                                     java.lang.String descendantName)
rootElement - holds the element for which its descendant element is to be found.descendantName - holds the name of the descendant to be found.
public static java.lang.String getElementValue(org.w3c.dom.Element element)
element - holds the element for which its value is to be retrieved.
public static void setElementValue(org.w3c.dom.Element element,
                                   java.lang.String value)
element - holds the element to be set the value.value - holds the value to set.
public static org.w3c.dom.Element createOSxLRootElement(org.w3c.dom.Document document,
                                                        java.lang.String osxlName)
document - holds the W3C DOM type document to create XML elements and attributes.
 It is the parent of the OSxL root element, e.g. the <OSiL> element in OSiL. It is used
 to create all the nodes in the DOM tree.osxlName - holds the OSxL name used to create the root element.
public static java.lang.String createXSDateTime(java.util.GregorianCalendar dateTime)
dateTime - holds the native date/time.
public static java.util.GregorianCalendar createNativeDateTime(java.lang.String xsDateTime)
xsDateTime - holds standard xs:dateTime in a string.
public static void main(java.lang.String[] args)
argv - command line arguments.
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||