|
TUM CCSM Commons | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.tum.cs.commons.xml.XMLUtils
public class XMLUtils
Collection of utility methods for XML.
| Constructor Summary | |
|---|---|
XMLUtils()
|
|
| Method Summary | |
|---|---|
static org.w3c.dom.Document |
createEmptyDocument()
Creates an empty XML document. |
static java.util.List<org.w3c.dom.Element> |
elementNodes(org.w3c.dom.NodeList nodeList)
Extracts all ElementNodes from a NodeList and returns the result as a list. |
static int |
getElementPosition(org.w3c.dom.Element element)
Determines the index (starting at 0) of the given element relative to other element nodes for the same parent. |
static org.w3c.dom.Element |
getNamedChild(org.w3c.dom.Element element,
java.lang.String name)
Returns the first child of the given element which is an element named as specified. |
static java.lang.String |
getNamedChildContent(org.w3c.dom.Element parent,
java.lang.String name)
Get the text content of the given element's first child that is an element named as specified. |
static java.util.List<org.w3c.dom.Element> |
getNamedChildren(org.w3c.dom.Element element,
java.lang.String elementNames)
Returns all children of the given element which are element named as specified. |
static java.util.List<org.w3c.dom.Element> |
leafElementNodes(org.w3c.dom.Element root)
Get all leaf elements of an XML tree rooted at an element |
static org.w3c.dom.Document |
parse(java.io.File file)
Parse a file without validation. |
static org.w3c.dom.Document |
parse(java.io.File file,
java.io.File schema)
Same as parse(File, URL) but with schema file. |
static org.w3c.dom.Document |
parse(java.io.File file,
java.net.URL schemaURL)
Parse and validate file using schema. |
static org.w3c.dom.Document |
parse(org.xml.sax.InputSource input)
Parse an input source without validation. |
static org.w3c.dom.Document |
parse(org.xml.sax.InputSource input,
java.net.URL schemaURL)
Parse and validate file using schema. |
static void |
parseSAX(java.io.File file,
org.xml.sax.helpers.DefaultHandler handler)
Parse an input source using SAX without validation. |
static void |
parseSAX(java.io.File file,
java.net.URL schemaURL,
org.xml.sax.helpers.DefaultHandler handler)
Parse and validate file using SAX and schema. |
static void |
parseSAX(org.xml.sax.InputSource input,
org.xml.sax.helpers.DefaultHandler handler)
Parse an input source using SAX without validation. |
static void |
parseSAX(org.xml.sax.InputSource input,
java.net.URL schemaURL,
org.xml.sax.helpers.DefaultHandler handler)
Parse and validate file using SAX and schema. |
static java.lang.String |
prettyPrint(org.w3c.dom.Document doc)
Returns a string representation of the given XML document, which is "pretty printed", i.e. the tags are indented. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLUtils()
| Method Detail |
|---|
public static org.w3c.dom.Document parse(java.io.File file)
throws org.xml.sax.SAXException,
java.io.IOException
file - the file to parse.
org.xml.sax.SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed.
java.io.IOException - if an IO exception occurs.
public static org.w3c.dom.Document parse(org.xml.sax.InputSource input)
throws org.xml.sax.SAXException,
java.io.IOException
input - the input source to parse
org.xml.sax.SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed.
java.io.IOException - if an IO exception occurs.
public static void parseSAX(java.io.File file,
org.xml.sax.helpers.DefaultHandler handler)
throws org.xml.sax.SAXException,
java.io.IOException
org.xml.sax.SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed.
java.io.IOException - if an IO exception occurs.
public static void parseSAX(org.xml.sax.InputSource input,
org.xml.sax.helpers.DefaultHandler handler)
throws org.xml.sax.SAXException,
java.io.IOException
org.xml.sax.SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed.
java.io.IOException - if an IO exception occurs.
public static org.w3c.dom.Document parse(java.io.File file,
java.net.URL schemaURL)
throws org.xml.sax.SAXException,
java.io.IOException
file - the file to parse.schemaURL - URL point to schema, may not be null
org.xml.sax.SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed or not valid
java.io.IOException - if an IO exception occurs.
public static org.w3c.dom.Document parse(org.xml.sax.InputSource input,
java.net.URL schemaURL)
throws org.xml.sax.SAXException,
java.io.IOException
input - the input to parse.schemaURL - URL point to schema, may not be null
org.xml.sax.SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed or not valid
java.io.IOException - if an IO exception occurs.
public static void parseSAX(java.io.File file,
java.net.URL schemaURL,
org.xml.sax.helpers.DefaultHandler handler)
throws org.xml.sax.SAXException,
java.io.IOException
file - the file to parse.schemaURL - URL point to schema, may not be null
org.xml.sax.SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed or not valid
java.io.IOException - if an IO exception occurs.
public static void parseSAX(org.xml.sax.InputSource input,
java.net.URL schemaURL,
org.xml.sax.helpers.DefaultHandler handler)
throws org.xml.sax.SAXException,
java.io.IOException
input - the input to parse.schemaURL - URL point to schema, may not be null
org.xml.sax.SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed or not valid
java.io.IOException - if an IO exception occurs.
public static org.w3c.dom.Document parse(java.io.File file,
java.io.File schema)
throws org.xml.sax.SAXException,
java.io.IOException
parse(File, URL) but with schema file.
java.lang.IllegalArgumentException - if the schema file could not be converted to an URL
org.xml.sax.SAXException
java.io.IOException
public static java.lang.String prettyPrint(org.w3c.dom.Document doc)
throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerExceptionpublic static int getElementPosition(org.w3c.dom.Element element)
public static java.util.List<org.w3c.dom.Element> getNamedChildren(org.w3c.dom.Element element,
java.lang.String elementNames)
public static org.w3c.dom.Element getNamedChild(org.w3c.dom.Element element,
java.lang.String name)
public static java.lang.String getNamedChildContent(org.w3c.dom.Element parent,
java.lang.String name)
public static java.util.List<org.w3c.dom.Element> elementNodes(org.w3c.dom.NodeList nodeList)
nodeList - the NodeList to be searched for ElementNodes.
public static java.util.List<org.w3c.dom.Element> leafElementNodes(org.w3c.dom.Element root)
root - The root element
public static org.w3c.dom.Document createEmptyDocument()
|
TUM CCSM Commons | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||