|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uk.org.ogsadai.common.XMLUtilities
ogsadai class/interface uk.org.ogsadai.common.XMLUtilities A collection of XML helper methods
| Constructor Summary | |
XMLUtilities()
|
|
| Method Summary | |
static org.w3c.dom.Document |
createEmptyDocument()
Creates a new empty Document. |
static java.util.Iterator |
getChildElementIterator(org.w3c.dom.Node parent)
Returns an iterator over the child elements of the specified node. |
static java.lang.String |
getTextContent(org.w3c.dom.Node node)
Gets the text content below of the specified node. |
static java.lang.String |
nodeToString(org.w3c.dom.Node node)
Converts anything that implements Node into a String. |
static java.lang.String |
removeComments(java.lang.String xml)
Removes any XML comments from the specified XML string. |
static java.lang.String |
removePrologue(java.lang.String xml)
Removes the XML prologue from the beginning of an XML string. |
static void |
xmlDOMToFile(org.w3c.dom.Document doc,
java.lang.String fileName)
Puts a DOM Document object into a new file |
static java.io.Reader |
xmlDOMToStream(org.w3c.dom.Document doc)
Returns a stream to the XML document This method is provided for completeness - it is preferable to use the xmlDOMToStream(Document doc, Writer stream) method as it includes no caching. |
static void |
xmlDOMToStream(org.w3c.dom.DocumentFragment doc,
java.io.OutputStream stream)
Writes the document to the stream |
static void |
xmlDOMToStream(org.w3c.dom.DocumentFragment doc,
java.io.Writer stream)
Writes the document to the stream |
static void |
xmlDOMToStream(org.w3c.dom.Document doc,
java.io.OutputStream stream)
Writes the document to the stream |
static void |
xmlDOMToStream(org.w3c.dom.Document doc,
java.io.Writer stream)
Writes the document to the stream |
static void |
xmlDOMToStream(org.w3c.dom.Element doc,
java.io.OutputStream stream)
Writes the document to the stream |
static void |
xmlDOMToStream(org.w3c.dom.Element doc,
java.io.Writer stream)
Writes the document to the stream |
static java.lang.String |
xmlDOMToString(org.w3c.dom.Document doc)
Converts a DOM Document object into a string |
static java.lang.String |
xmlDOMToString(org.w3c.dom.DocumentFragment doc)
Converts a DOM DocumentFragment object into a string |
static java.lang.String |
xmlDOMToString(org.w3c.dom.Element element)
Converts a DOM Element object into a string |
static org.w3c.dom.Document |
xmlFileToDOM(java.lang.String fileName)
Converts the XML contents of a file into a DOM Document object |
static org.w3c.dom.Document |
xmlFileToDOM(java.lang.String fileName,
boolean validate)
Converts the XML contents of a file into a DOM Document object |
static org.w3c.dom.Document |
xmlStreamToDOM(java.io.InputStream stream)
Converts the XML contents of a stream into a DOM Document object |
static org.w3c.dom.Document |
xmlStreamToDOM(java.io.InputStream stream,
boolean validate)
Converts the XML contents of a stream into a DOM Document object |
static org.w3c.dom.Document |
xmlStreamToDOM(java.io.InputStream stream,
java.lang.String schemaPath)
Parses the XML contents of an InputStream into a DOM
Document and validates the document against the specified
schema. |
static org.w3c.dom.Document |
xmlStringToDOM(java.lang.String xmlString)
Parses xml in string format into a DOM Document object |
static org.w3c.dom.Document |
xmlStringToDOM(java.lang.String xmlString,
boolean validate)
Parses xml in string format into a DOM Document object |
static org.w3c.dom.Document |
xmlStringToDOM(java.lang.String xml,
java.lang.String schemaLocation)
Parses an XML String into a DOM Document
object and validates the document against the specified schema. |
static org.w3c.dom.Document |
xmlURLToDOM(java.net.URL url)
Converts the XML contents of a file that is retrieved via a URL into a DOM Document object |
static org.w3c.dom.Document |
xmlURLToDOM(java.net.URL url,
boolean validate)
Converts the XML contents of a file that is retrieved via a URL into a DOM Document object |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public XMLUtilities()
| Method Detail |
public static org.w3c.dom.Document xmlURLToDOM(java.net.URL url)
throws CommonSystemException,
CommonUserException
url - The URL of the file to convert
CommonSystemException
CommonUserException
public static org.w3c.dom.Document xmlURLToDOM(java.net.URL url,
boolean validate)
throws CommonSystemException,
CommonUserException
url - The URL of the file to convertvalidate - A boolean flag to indicate if schema validation is required
CommonSystemException
CommonUserException
public static org.w3c.dom.Document xmlFileToDOM(java.lang.String fileName)
throws CommonSystemException,
CommonUserException
fileName - The file to convert
CommonSystemException
CommonUserException
public static org.w3c.dom.Document xmlFileToDOM(java.lang.String fileName,
boolean validate)
throws CommonSystemException,
CommonUserException
fileName - The name of the file to convertvalidate - A boolean flag to indicate if schema validation is required
CommonSystemException
CommonUserException
public static org.w3c.dom.Document xmlStringToDOM(java.lang.String xmlString)
throws CommonUserException
xmlString - java.lang.String The xml in a String object
CommonUserException
public static org.w3c.dom.Document xmlStringToDOM(java.lang.String xmlString,
boolean validate)
throws CommonUserException
xmlString - java.lang.String The xml in a String objectvalidate - boolean Whether or not the XML should be validated
CommonUserException
public static org.w3c.dom.Document xmlStringToDOM(java.lang.String xml,
java.lang.String schemaLocation)
throws CommonUserException
String into a DOM Document
object and validates the document against the specified schema.
xml - a String containing XML dataschemaLocation - the namespace and location of the schema, in the same format
as the standard XML xsi:schemaLocation
attribute. For example:
"http://ogsadai.org.uk/namespaces/2004/11/core/supported_activities schema/ogsadai/xsd/supported_activities.xsd"
CommonUserException
public static org.w3c.dom.Document xmlStreamToDOM(java.io.InputStream stream)
throws CommonUserException
stream - The stream to convert
CommonUserException
public static org.w3c.dom.Document xmlStreamToDOM(java.io.InputStream stream,
boolean validate)
throws CommonUserException
stream - The stream to convertvalidate - A boolean flag to indicate if schema validation is required
CommonUserException
public static org.w3c.dom.Document xmlStreamToDOM(java.io.InputStream stream,
java.lang.String schemaPath)
throws CommonUserException
InputStream into a DOM
Document and validates the document against the specified
schema.
stream - an InputStream containing XML dataschemaPath - the namespace and location of the schema, in the same format
as the standard XML xsi:schemaLocation
attribute. For example:
"http://ogsadai.org.uk/namespaces/2004/11/core/supported_activities schema/ogsadai/xsd/supported_activities.xsd"
CommonUserException
public static java.lang.String nodeToString(org.w3c.dom.Node node)
throws CommonSystemException
Node into a String.
node - The Node to convert.
String representation of the node.
CommonSystemException - If there is a problem converting the node.
public static java.lang.String xmlDOMToString(org.w3c.dom.Document doc)
throws CommonSystemException
doc - The document to convert
CommonSystemException
public static java.lang.String xmlDOMToString(org.w3c.dom.DocumentFragment doc)
throws CommonSystemException
doc - The document to convert
CommonSystemException
public static java.lang.String xmlDOMToString(org.w3c.dom.Element element)
throws CommonSystemException
element - The document to convert
CommonSystemException
public static void xmlDOMToFile(org.w3c.dom.Document doc,
java.lang.String fileName)
throws CommonUserException,
CommonSystemException
doc - The document to convert
CommonUserException
CommonSystemException
public static java.io.Reader xmlDOMToStream(org.w3c.dom.Document doc)
throws CommonSystemException
doc - The document to convert
CommonSystemException
public static void xmlDOMToStream(org.w3c.dom.Document doc,
java.io.Writer stream)
throws CommonSystemException
doc - The document to writestream - The stream to write to
CommonSystemException
public static void xmlDOMToStream(org.w3c.dom.DocumentFragment doc,
java.io.Writer stream)
throws CommonSystemException
doc - The document to writestream - The stream to write to
CommonSystemException
public static void xmlDOMToStream(org.w3c.dom.Element doc,
java.io.Writer stream)
throws CommonSystemException
doc - The document to writestream - The stream to write to
CommonSystemException
public static void xmlDOMToStream(org.w3c.dom.Document doc,
java.io.OutputStream stream)
throws CommonSystemException
doc - The document to writestream - The stream to write to
CommonSystemException
public static void xmlDOMToStream(org.w3c.dom.DocumentFragment doc,
java.io.OutputStream stream)
throws CommonSystemException
doc - The document to writestream - The stream to write to
CommonSystemException
public static void xmlDOMToStream(org.w3c.dom.Element doc,
java.io.OutputStream stream)
throws CommonSystemException
doc - The document to writestream - The stream to write to
CommonSystemExceptionpublic static java.lang.String removePrologue(java.lang.String xml)
xml - a String containing XML
String containing the same XML data with the XML
prologue removed, or unchanged if there is no prologue
public static java.lang.String removeComments(java.lang.String xml)
throws CommonSystemException,
CommonUserException
xml - a String containing XML
String containing the same XML data with the
comments removed
CommonUserException
CommonSystemExceptionpublic static java.lang.String getTextContent(org.w3c.dom.Node node)
node - the Node
String containing a concatenation of the text
children of the specified node, or an empty string if there are
no child nodespublic static java.util.Iterator getChildElementIterator(org.w3c.dom.Node parent)
parent - the parent node
java.util.Iterator containing Element
objectspublic static org.w3c.dom.Document createEmptyDocument()
Document.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||