public class XMLUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static javax.xml.parsers.DocumentBuilder |
createBuilder(org.xml.sax.EntityResolver entityResolver)
Creates a DocumentBuilder with the specified entity resolver.
|
static org.w3c.dom.Document |
newDocument()
Creates an empty DOM document.
|
static org.w3c.dom.Document |
parse(java.io.File file)
Parses the document represented by the file.
|
static org.w3c.dom.Document |
parse(java.io.File file,
org.xml.sax.EntityResolver entityResolver)
Parses the document represented by the file.
|
static org.w3c.dom.Document |
parse(org.xml.sax.InputSource source)
Parses the document represented by the input source.
|
static org.w3c.dom.Document |
parse(org.xml.sax.InputSource source,
org.xml.sax.EntityResolver entityResolver)
Parses the document represented by the input source.
|
static org.w3c.dom.Document |
parse(java.io.InputStream in)
Parses the document represented by the input stream.
|
static org.w3c.dom.Document |
parse(java.io.InputStream in,
org.xml.sax.EntityResolver entityResolver)
Parses the document represented by the input stream.
|
static org.w3c.dom.Document |
parse(java.lang.String xml)
Parses the document represented by the string.
|
static org.w3c.dom.Document |
parse(java.lang.String xml,
org.xml.sax.EntityResolver entityResolver)
Parses the document represented by the string.
|
static java.lang.String |
prettyPrint(org.w3c.dom.Document document)
Serializes a document into a String, with pretty indentations.
|
static void |
prettyPrint(org.w3c.dom.Document document,
java.io.Writer writer)
Serializes the document to the writer.
|
static java.io.InputStream |
serialize(org.w3c.dom.Document document)
Serializes the document and returns the input stream from which to read
the result from.
|
static void |
serialize(org.w3c.dom.Document document,
java.io.OutputStream out)
Serializes the document to the output stream.
|
static void |
serialize(org.w3c.dom.Document document,
java.io.Writer writer)
Serializes the document to the writer.
|
static java.io.InputStream |
transform(javax.xml.transform.Source xml,
javax.xml.transform.Source xsl)
Transforms the xml using the xsl and returns an input stream from which
the result can be read.
|
static void |
transform(javax.xml.transform.Source xml,
javax.xml.transform.Source xsl,
java.io.OutputStream out)
Transforms the xml using the xsl to the output stream.
|
static void |
transform(javax.xml.transform.Source xml,
javax.xml.transform.Source xsl,
java.io.OutputStream out,
java.util.Properties params)
Transforms the xml using the xsl to the output stream.
|
public static java.io.InputStream transform(javax.xml.transform.Source xml, javax.xml.transform.Source xsl) throws org.xml.sax.SAXException, javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException, java.io.IOException
xml
- the xml document to transform.xsl
- the xsl to use when transforming.org.xml.sax.SAXException
- if unable to parse any of the documents.javax.xml.transform.TransformerConfigurationException
- if unable to create
transformer.javax.xml.transform.TransformerException
- if unable to transform.java.io.IOException
- if an input/output error occurs.public static void transform(javax.xml.transform.Source xml, javax.xml.transform.Source xsl, java.io.OutputStream out) throws org.xml.sax.SAXException, javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException, java.io.IOException
xml
- the xml document to transform.xsl
- the xsl to use when transforming.out
- the output stream to transform to.org.xml.sax.SAXException
- if unable to parse any of the documents.javax.xml.transform.TransformerConfigurationException
- if unable to create
transformer.javax.xml.transform.TransformerException
- if unable to transform.java.io.IOException
- if an input/output error occurs.public static void transform(javax.xml.transform.Source xml, javax.xml.transform.Source xsl, java.io.OutputStream out, java.util.Properties params) throws javax.xml.transform.TransformerException, java.io.IOException
xml
- the xml document to transform.xsl
- the xsl to use when transforming.out
- the output stream to transform to.params
- The parameters to pass to the processor.org.xml.sax.SAXException
- if unable to parse any of the documents.javax.xml.transform.TransformerConfigurationException
- if unable to create
transformer.javax.xml.transform.TransformerException
- if unable to transform.java.io.IOException
- if an input/output error occurs.public static javax.xml.parsers.DocumentBuilder createBuilder(org.xml.sax.EntityResolver entityResolver) throws javax.xml.parsers.ParserConfigurationException
entityResolver
- the EntityResolver to use.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.public static org.w3c.dom.Document newDocument() throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
- If unable to create the document.public static org.w3c.dom.Document parse(java.io.File file) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
file
- the file containing the document to parse.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.org.xml.sax.SAXException
- if unable to parse the document.java.io.IOException
- if an input/output error occurs.public static org.w3c.dom.Document parse(java.io.File file, org.xml.sax.EntityResolver entityResolver) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
file
- the file containing the document to parse.entityResolver
- the EntityResolver to use.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.org.xml.sax.SAXException
- if unable to parse the document.java.io.IOException
- if an input/output error occurs.public static org.w3c.dom.Document parse(org.xml.sax.InputSource source) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
source
- the input source representing the document to parse.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.org.xml.sax.SAXException
- if unable to parse the document.java.io.IOException
- if an input/output error occurs.public static org.w3c.dom.Document parse(org.xml.sax.InputSource source, org.xml.sax.EntityResolver entityResolver) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
source
- the input source representing the document to parse.entityResolver
- the EntityResolver to use.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.org.xml.sax.SAXException
- if unable to parse the document.java.io.IOException
- if an input/output error occurs.public static org.w3c.dom.Document parse(java.io.InputStream in) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
in
- the input stream representing the document to parse.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.org.xml.sax.SAXException
- if unable to parse the document.java.io.IOException
- if an input/output error occurs.public static org.w3c.dom.Document parse(java.io.InputStream in, org.xml.sax.EntityResolver entityResolver) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
in
- the input stream representing the document to parse.entityResolver
- the EntityResolver to use.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.org.xml.sax.SAXException
- if unable to parse the document.java.io.IOException
- if an input/output error occurs.public static org.w3c.dom.Document parse(java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
xml
- the string representing the document to parse.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.org.xml.sax.SAXException
- if unable to parse the document.java.io.IOException
- if an input/output error occurs.public static org.w3c.dom.Document parse(java.lang.String xml, org.xml.sax.EntityResolver entityResolver) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
xml
- the string representing the document to parse.entityResolver
- the EntityResolver to use.javax.xml.parsers.ParserConfigurationException
- if unable to create document
builder.org.xml.sax.SAXException
- if unable to parse the document.java.io.IOException
- if an input/output error occurs.public static java.io.InputStream serialize(org.w3c.dom.Document document) throws java.io.IOException, javax.xml.transform.TransformerException
document
- the document to serialize.java.io.IOException
- if an input/output error occurs.javax.xml.transform.TransformerException
public static void serialize(org.w3c.dom.Document document, java.io.OutputStream out) throws java.io.IOException, javax.xml.transform.TransformerException
document
- the document to serialize.out
- the output stream to serialize into.IOException,
- TransformerExceptionjava.io.IOException
javax.xml.transform.TransformerException
public static void serialize(org.w3c.dom.Document document, java.io.Writer writer) throws java.io.IOException, javax.xml.transform.TransformerException
document
- the document to serialize.writer
- the writer to serialize into.IOException,
- TransformerExceptionjava.io.IOException
javax.xml.transform.TransformerException
public static void prettyPrint(org.w3c.dom.Document document, java.io.Writer writer) throws java.io.IOException, javax.xml.transform.TransformerException
document
- writer
- java.io.IOException
javax.xml.transform.TransformerException
public static java.lang.String prettyPrint(org.w3c.dom.Document document)
document
- The document.Copyright ? Technia AB. All Rights Reserved.