|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lenya.xml.DocumentHelper
public class DocumentHelper
Various utility methods to work with JAXP.
Constructor Summary | |
---|---|
DocumentHelper()
|
Method Summary | |
---|---|
static javax.xml.parsers.DocumentBuilder |
createBuilder()
Creates a non-validating and namespace-aware DocumentBuilder. |
static org.w3c.dom.Document |
createDocument(java.lang.String namespaceUri,
java.lang.String qualifiedName,
org.w3c.dom.DocumentType documentType)
Creates a document. |
org.w3c.dom.DocumentType |
createDocumentType(java.lang.String qualifiedName,
java.lang.String publicId,
java.lang.String systemId)
Creates a document type. |
static org.w3c.dom.Element[] |
getChildren(org.w3c.dom.Element element)
Returns all child elements of an element, regardless of the namespace. |
static org.w3c.dom.Element[] |
getChildren(org.w3c.dom.Element element,
java.lang.String namespaceUri)
Returns all child elements of an element that belong to a certain namespace. |
static org.w3c.dom.Element[] |
getChildren(org.w3c.dom.Element element,
java.lang.String namespaceUri,
java.lang.String localName)
Returns all child elements of an element that belong to a certain namespace and have a certain local name. |
static org.w3c.dom.Element |
getFirstChild(org.w3c.dom.Element element,
java.lang.String namespaceUri)
Returns the first child element of an element that belong to a certain namespace or null if none exists. |
static org.w3c.dom.Element |
getFirstChild(org.w3c.dom.Element element,
java.lang.String namespaceUri,
java.lang.String localName)
Returns the first child element of an element that belongs to a certain namespace and has a certain local name or null if none
exists. |
static org.w3c.dom.Element[] |
getNextSiblings(org.w3c.dom.Element element,
java.lang.String namespaceUri)
Returns all following sibling elements of an element that belong to a certain namespace. |
static org.w3c.dom.Element[] |
getNextSiblings(org.w3c.dom.Element element,
java.lang.String namespaceUri,
java.lang.String localName)
Returns all following sibling elements of an element that belong to a certain namespace. and have a certain local name. |
static org.w3c.dom.Element[] |
getPrecedingSiblings(org.w3c.dom.Element element,
java.lang.String namespaceUri)
Returns all preceding sibling elements of an element that belong to a certain namespace. |
static org.w3c.dom.Element[] |
getPrecedingSiblings(org.w3c.dom.Element element,
java.lang.String namespaceUri,
java.lang.String localName)
Returns all preceding sibling elements of an element that belong to a certain namespace. and have a certain local name. |
static java.lang.String |
getSimpleElementText(org.w3c.dom.Element element)
Returns the text inside an element. |
protected static javax.xml.transform.Transformer |
getTransformer(org.w3c.dom.DocumentType documentType)
Get the transformer. |
static org.w3c.dom.Document |
readDocument(java.io.File file)
Reads a document from a file. |
static org.w3c.dom.Document |
readDocument(java.io.InputStream stream)
Reads a document from an input stream. |
static org.w3c.dom.Document |
readDocument(java.lang.String string,
java.lang.String encoding)
Reads a document from a string. |
static org.w3c.dom.Document |
readDocument(java.net.URI uri)
Reads a document from a URI. |
static org.w3c.dom.Document |
readDocument(java.net.URL url)
Reads a document from a URL. |
static void |
setSimpleElementText(org.w3c.dom.Element element,
java.lang.String text)
Replaces all child nodes of an element by a single text node. |
static void |
writeDocument(org.w3c.dom.Document document,
java.io.File file)
Writes a document to a file. |
static void |
writeDocument(org.w3c.dom.Document document,
java.io.OutputStream outputStream)
Writes a document to an output stream. |
static void |
writeDocument(org.w3c.dom.Document document,
java.io.Writer writer)
Writes a document to a writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DocumentHelper()
Method Detail |
---|
public static javax.xml.parsers.DocumentBuilder createBuilder() throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
- if an error occurspublic static org.w3c.dom.Document createDocument(java.lang.String namespaceUri, java.lang.String qualifiedName, org.w3c.dom.DocumentType documentType) throws org.w3c.dom.DOMException, javax.xml.parsers.ParserConfigurationException
namespaceUri
- The namespace URL of the root element.qualifiedName
- The qualified name of the root element.documentType
- The type of document to be created or null. When
doctype is not null, its Node.ownerDocument attribute is set
to the document being created.
org.w3c.dom.DOMException
- if an error occurs
javax.xml.parsers.ParserConfigurationException
- if an error occursDOMImplementation.createDocument(String, String,
DocumentType)
public static org.w3c.dom.Document readDocument(java.io.File file) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
file
- The file to load the document from.
javax.xml.parsers.ParserConfigurationException
- if an error occurs
org.xml.sax.SAXException
- if an error occurs
java.io.IOException
- if an error occurspublic static org.w3c.dom.Document readDocument(java.net.URL url) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
url
- The URL to load the document from.
javax.xml.parsers.ParserConfigurationException
- if an error occurs
org.xml.sax.SAXException
- if an error occurs
java.io.IOException
- if an error occurspublic static org.w3c.dom.Document readDocument(java.net.URI uri) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
uri
- The URI to load the document from.
javax.xml.parsers.ParserConfigurationException
- if an error occurs
org.xml.sax.SAXException
- if an error occurs
java.io.IOException
- if an error occurspublic static org.w3c.dom.Document readDocument(java.lang.String string, java.lang.String encoding) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
string
- The string to load the document from.encoding
- The encoding which is used by the string.
javax.xml.parsers.ParserConfigurationException
- if an error occurs
org.xml.sax.SAXException
- if an error occurs
java.io.IOException
- if an error occurspublic static org.w3c.dom.Document readDocument(java.io.InputStream stream) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
stream
- The input stream to load the document from.
javax.xml.parsers.ParserConfigurationException
- if an error occurs
org.xml.sax.SAXException
- if an error occurs
java.io.IOException
- if an error occurspublic static void writeDocument(org.w3c.dom.Document document, java.io.File file) throws javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException, java.io.IOException
document
- The document to save.file
- The file to save the document to.
java.io.IOException
- if an error occurs
javax.xml.transform.TransformerConfigurationException
- if an error occurs
javax.xml.transform.TransformerException
- if an error occurspublic static void writeDocument(org.w3c.dom.Document document, java.io.Writer writer) throws javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException
document
- The document to write.writer
- The writer to write the document to.
javax.xml.transform.TransformerConfigurationException
- if an error occurs
javax.xml.transform.TransformerException
- if an error occurspublic static void writeDocument(org.w3c.dom.Document document, java.io.OutputStream outputStream) throws javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException
document
- The document to write.outputStream
- The stream to write the document to.
javax.xml.transform.TransformerConfigurationException
- if an error occurs
javax.xml.transform.TransformerException
- if an error occursprotected static javax.xml.transform.Transformer getTransformer(org.w3c.dom.DocumentType documentType) throws javax.xml.transform.TransformerConfigurationException
documentType
- the document type
javax.xml.transform.TransformerConfigurationException
- if an error occurspublic org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicId, java.lang.String systemId) throws javax.xml.parsers.ParserConfigurationException
qualifiedName
- The qualified name of the document type.publicId
- The public identifier.systemId
- The system identifier.
javax.xml.parsers.ParserConfigurationException
- if an error occursDOMImplementation.createDocumentType(java.lang.String,
java.lang.String, java.lang.String)
public static org.w3c.dom.Element getFirstChild(org.w3c.dom.Element element, java.lang.String namespaceUri)
null
if none exists.
element
- The parent element.namespaceUri
- The namespace that the childen must belong to.
null
if none exists.public static org.w3c.dom.Element getFirstChild(org.w3c.dom.Element element, java.lang.String namespaceUri, java.lang.String localName)
null
if none
exists.
element
- The parent element.namespaceUri
- The namespace that the childen must belong to.localName
- The local name of the children.
null
if none exists.public static org.w3c.dom.Element[] getChildren(org.w3c.dom.Element element)
element
- The parent element.
public static org.w3c.dom.Element[] getChildren(org.w3c.dom.Element element, java.lang.String namespaceUri)
element
- The parent element.namespaceUri
- The namespace that the childen must belong to.
public static org.w3c.dom.Element[] getChildren(org.w3c.dom.Element element, java.lang.String namespaceUri, java.lang.String localName)
element
- The parent element.namespaceUri
- The namespace that the childen must belong to.localName
- The local name of the children.
public static java.lang.String getSimpleElementText(org.w3c.dom.Element element)
element
- The element.
public static void setSimpleElementText(org.w3c.dom.Element element, java.lang.String text)
element
- The element.text
- The text to insert.public static org.w3c.dom.Element[] getNextSiblings(org.w3c.dom.Element element, java.lang.String namespaceUri)
element
- The parent element.namespaceUri
- The namespace that the childen must belong to.
public static org.w3c.dom.Element[] getNextSiblings(org.w3c.dom.Element element, java.lang.String namespaceUri, java.lang.String localName)
element
- The parent element.namespaceUri
- The namespace that the childen must belong to.localName
- The local name of the children.
public static org.w3c.dom.Element[] getPrecedingSiblings(org.w3c.dom.Element element, java.lang.String namespaceUri)
element
- The parent element.namespaceUri
- The namespace that the childen must belong to.
public static org.w3c.dom.Element[] getPrecedingSiblings(org.w3c.dom.Element element, java.lang.String namespaceUri, java.lang.String localName)
element
- The parent element.namespaceUri
- The namespace that the childen must belong to.localName
- The local name of the children.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |