|
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 Document |
createEmptyDocument()
Creates an empty XML document. |
static List<Element> |
elementNodes(NodeList nodeList)
Extracts all ElementNodes from a NodeList and returns the result as a list. |
static int |
getElementPosition(Element element)
Determines the index (starting at 0) of the given element relative to other element nodes for the same parent. |
static Element |
getNamedChild(Element element,
String name)
Returns the first child of the given element which is an element named as specified. |
static String |
getNamedChildContent(Element parent,
String name)
Get the text content of the given element's first child that is an element named as specified. |
static List<Element> |
getNamedChildren(Element element,
String elementNames)
Returns all children of the given element which are element named as specified. |
static List<Element> |
leafElementNodes(Element root)
Get all leaf elements of an XML tree rooted at an element |
static Document |
parse(File file)
Parse a file without validation. |
static Document |
parse(File file,
File schema)
Same as parse(File, URL) but with schema file. |
static Document |
parse(File file,
URL schemaURL)
Parse and validate file using schema. |
static Document |
parse(InputSource input)
Parse an input source without validation. |
static Document |
parse(InputSource input,
URL schemaURL)
Parse and validate file using schema. |
static void |
parseSAX(File file,
DefaultHandler handler)
Parse an input source using SAX without validation. |
static void |
parseSAX(File file,
URL schemaURL,
DefaultHandler handler)
Parse and validate file using SAX and schema. |
static void |
parseSAX(InputSource input,
DefaultHandler handler)
Parse an input source using SAX without validation. |
static void |
parseSAX(InputSource input,
URL schemaURL,
DefaultHandler handler)
Parse and validate file using SAX and schema. |
static String |
prettyPrint(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 Document parse(File file)
throws SAXException,
IOException
file - the file to parse.
SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed.
IOException - if an IO exception occurs.
public static Document parse(InputSource input)
throws SAXException,
IOException
input - the input source to parse
SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed.
IOException - if an IO exception occurs.
public static void parseSAX(File file,
DefaultHandler handler)
throws SAXException,
IOException
SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed.
IOException - if an IO exception occurs.
public static void parseSAX(InputSource input,
DefaultHandler handler)
throws SAXException,
IOException
SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed.
IOException - if an IO exception occurs.
public static Document parse(File file,
URL schemaURL)
throws SAXException,
IOException
file - the file to parse.schemaURL - URL point to schema, may not be null
SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed or not valid
IOException - if an IO exception occurs.
public static Document parse(InputSource input,
URL schemaURL)
throws SAXException,
IOException
input - the input to parse.schemaURL - URL point to schema, may not be null
SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed or not valid
IOException - if an IO exception occurs.
public static void parseSAX(File file,
URL schemaURL,
DefaultHandler handler)
throws SAXException,
IOException
file - the file to parse.schemaURL - URL point to schema, may not be null
SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed or not valid
IOException - if an IO exception occurs.
public static void parseSAX(InputSource input,
URL schemaURL,
DefaultHandler handler)
throws SAXException,
IOException
input - the input to parse.schemaURL - URL point to schema, may not be null
SAXException - if a parsing exception occurs, i.e. if the file is not
well-formed or not valid
IOException - if an IO exception occurs.
public static Document parse(File file,
File schema)
throws SAXException,
IOException
parse(File, URL) but with schema file.
IllegalArgumentException - if the schema file could not be converted to an URL
SAXException
IOException
public static String prettyPrint(Document doc)
throws TransformerException
TransformerExceptionpublic static int getElementPosition(Element element)
public static List<Element> getNamedChildren(Element element,
String elementNames)
public static Element getNamedChild(Element element,
String name)
public static String getNamedChildContent(Element parent,
String name)
public static List<Element> elementNodes(NodeList nodeList)
nodeList - the NodeList to be searched for ElementNodes.
public static List<Element> leafElementNodes(Element root)
root - The root element
public static Document createEmptyDocument()
|
TUM CCSM Commons | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||