|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.gx.webmanager.handler.util.XMLUtil
public class XMLUtil
Various xml manipulation methods.
| Method Summary | |
|---|---|
static org.w3c.dom.Document |
createXmlDoc(java.lang.String xml)
Creates a document for xml input. |
static java.lang.String |
doc2Xml(org.w3c.dom.Document doc)
Converts a document to xml. |
static java.lang.String |
escapeToXML(java.lang.String value)
Escapes special xml characters. |
static java.lang.String |
getAttribute(org.w3c.dom.Node node,
java.lang.String attributeName)
Return the attribute with a specified name from a node. |
static java.lang.String |
getChildContents(org.w3c.dom.Node node,
java.lang.String childName)
Return the text representation of the first child of the node with the specified name. |
static org.w3c.dom.Node |
getChildNode(org.w3c.dom.Node parent,
java.lang.String childName)
Return the first child of the node with the specified name. |
static org.w3c.dom.Node[] |
getChildNodes(org.w3c.dom.Node parent,
java.lang.String childName)
Return the children of the node with the specified name. |
static java.lang.String |
getFileContents(java.lang.String fileName)
Extracts the contents of a file. |
static java.lang.String |
getTextContents(org.w3c.dom.Node node)
Extracts the text content of a node. |
static void |
main(java.lang.String[] args)
Main method that reads an xsl and xml file and returns the transformation result. |
static java.lang.String |
node2Xml(org.w3c.dom.Node node)
Converts a node to xml. |
static java.lang.String |
normalize(java.lang.String xml)
Normalizes an xml string. |
static void |
transform(java.lang.String stylesheet,
java.io.Reader in,
java.io.Writer out)
Transforms xml from the input reader and writes the result to the writer. |
static java.lang.String |
transform(java.lang.String stylesheet,
java.lang.String xmlData)
Transform xml with a stylesheet and return the result. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String getChildContents(org.w3c.dom.Node node,
java.lang.String childName)
node - The parent nodechildName - The name of the child of which the text should be returned.
null
if such a child could not be found.
public static org.w3c.dom.Node getChildNode(org.w3c.dom.Node parent,
java.lang.String childName)
node - The parent nodechildName - The name of the child that should be returned.
null
if such a child could not be found.
public static org.w3c.dom.Node[] getChildNodes(org.w3c.dom.Node parent,
java.lang.String childName)
node - The parent nodechildName - The name of the children that should be returned.
public static java.lang.String escapeToXML(java.lang.String value)
value - The string that should be escaped.
value value argument.
public static java.lang.String getAttribute(org.w3c.dom.Node node,
java.lang.String attributeName)
node - The parent node of which the attribute should be returned.attributeName - The name of the attribute that should be matched.
null
if the attribute could not be foundpublic static java.lang.String getTextContents(org.w3c.dom.Node node)
node - The node of which the text representation should be returned.
null if the argument is
invalid.
public static org.w3c.dom.Document createXmlDoc(java.lang.String xml)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
xml - The xml that should be parsed and converted to a document.
xml input.
javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder
cannot be created which satisfies the configuration requested.
org.xml.sax.SAXException - If the source could not be parsed.
java.io.IOException - If an IO error occurs.
public static java.lang.String normalize(java.lang.String xml)
throws org.xml.sax.SAXException
xml - The xml that should be normalized
org.xml.sax.SAXException - if the source could not be parsed.
public static java.lang.String node2Xml(org.w3c.dom.Node node)
throws javax.xml.transform.TransformerException
node - The node for which the xml representation should be returned.
javax.xml.transform.TransformerException - if the contents of the node could not be normalized.
public static java.lang.String doc2Xml(org.w3c.dom.Document doc)
throws javax.xml.transform.TransformerException
node - The document for which the xml representation should be returned.
javax.xml.transform.TransformerException - if the contents of the document could not be normalized.
public static java.lang.String transform(java.lang.String stylesheet,
java.lang.String xmlData)
throws javax.xml.transform.TransformerException
stylesheet - the xsl stylesheetxmlData - the xml
javax.xml.transform.TransformerException - if something goes wrong during the transformation
public static void transform(java.lang.String stylesheet,
java.io.Reader in,
java.io.Writer out)
throws javax.xml.transform.TransformerException
stylesheet - the xsl stylesheetin - the xml input readerout - the writer for the transformation result
javax.xml.transform.TransformerException - if something goes wrong during the transformationpublic static void main(java.lang.String[] args)
args - The file arguments
public static java.lang.String getFileContents(java.lang.String fileName)
throws java.io.IOException
fileName - The absolute path to the file.
java.io.IOException - if the file could not be read.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||