VLJ Iteration II, v. 1.0.0.193

gov.va.med.foundations.xml
Class XmlUtilities

java.lang.Object
  |
  +--gov.va.med.foundations.xml.XmlUtilities

public class XmlUtilities
extends java.lang.Object

This class contains a number of static utility methods to help developers work with XML documents, nodes, attributes and strings

Version:
1.0.0.193
Author:
Application Modernization - Foundations Team

Field Summary
static java.lang.String XML_HEADER
          Represents the default header used for all xml documents that communicate with an M server via VistALink.
 
Constructor Summary
XmlUtilities()
           
 
Method Summary
static java.lang.String convertXmlToStr(org.w3c.dom.Document doc)
          Method ConvertXmlToStr.
static org.w3c.dom.Attr getAttr(org.w3c.dom.Node node, java.lang.String attrName)
          Method getAttr.
static org.w3c.dom.Document getDocumentForXmlInputStream(java.io.InputStream xml)
          Method getDocumentForXmlInputStream.
static org.w3c.dom.Document getDocumentForXmlString(java.lang.String xml)
          Method getDocumentForXmlString.
static org.w3c.dom.Node getNode(java.lang.String xpathStr, org.w3c.dom.Node node)
          Method getNode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_HEADER

public static final java.lang.String XML_HEADER
Represents the default header used for all xml documents that communicate with an M server via VistALink. It is important to use this header as keeps the client and M server in sync.

See Also:
Constant Field Values
Constructor Detail

XmlUtilities

public XmlUtilities()
Method Detail

convertXmlToStr

public static java.lang.String convertXmlToStr(org.w3c.dom.Document doc)
                                        throws FoundationsException
Method ConvertXmlToStr.
Converts a DOM document to a string

Parameters:
doc -
Returns:
String
Throws:
FoundationsException

getNode

public static org.w3c.dom.Node getNode(java.lang.String xpathStr,
                                       org.w3c.dom.Node node)
Method getNode.
Returns the first node at the specified XPath location
Example: This example returns the Customer/Address node in the specified document object
Node address = XmlUtilities.getNode("/Customer/Address", custDoc);

Parameters:
xpathStr - - XPath str
node - - Node to search
Returns:
Node - first node found

getAttr

public static org.w3c.dom.Attr getAttr(org.w3c.dom.Node node,
                                       java.lang.String attrName)
Method getAttr.
Returns the Attribute with the given attrName at node
Example
This example returns the 'state' attribute from the address node: Attr state = getAttr(address,"state")

Parameters:
node - - Node to search
attrName - - Name of the attribute to find
Returns:
Attr - Attribute found

getDocumentForXmlString

public static org.w3c.dom.Document getDocumentForXmlString(java.lang.String xml)
                                                    throws FoundationsException
Method getDocumentForXmlString.
Returns an XML DOM Document for the specified String
Example:
This example creates a customer XML document for a serialized customer
Document cust = XmlUtilities.getDocumentForXmlString(custXmlString);

Parameters:
xml - - serialized XML document
Returns:
Document - XML document
Throws:
FoundationsException

getDocumentForXmlInputStream

public static org.w3c.dom.Document getDocumentForXmlInputStream(java.io.InputStream xml)
                                                         throws FoundationsException
Method getDocumentForXmlInputStream.
Returns an XML DOM Document for the specified InputStream
Example:
This example creates a customer XML document from an input stream
Document cust = XmlUtilities.getDocumentForXmlInputStream(custStream);

Parameters:
xml - - input stream to processed
Returns:
Document - XML document
Throws:
FoundationsException

VLJ Iteration II, v. 1.0.0.193

VistaLink Iteration II, v. 1.0.0.193