org.grinvin.xml

Class XMLUtils


public final class XMLUtils
extends java.lang.Object

Helper methods for XML-processing.

Method Summary

static Document
loadDocumentFromInputStream(InputStream stream)
static Element
loadFromClassPath(ClassLoader classLoader, String filename)
Converts the given XML file into a JDOM element.
static Element
loadFromClassPath(String filename)
Converts the given XML file into a JDOM element.
static Element
loadFromInputStream(InputStream stream)
Converts the given XML on the input stream into a JDOM element with all external entities (mainly DTDs) searched for in the package org.grinvin.dtds, but resolved by the class loader of this class.
static Element
loadFromInputStreamNonValidating(InputStream stream)

Method Details

loadDocumentFromInputStream

public static Document loadDocumentFromInputStream(InputStream stream)
            throws JDOMException,
                   IOException

loadFromClassPath

public static Element loadFromClassPath(ClassLoader classLoader,
                                        String filename)
            throws IOException
Converts the given XML file into a JDOM element. The file will be loaded by the given class loader and all external entities (mainly DTDs) are searched for in the package org.grinvin.dtds, but resolved by the class loader of this class.
Parameters:
classLoader - Class loader to be used for loading the XML file.
filename - Filename relative to the root of the class path, must not start with a slash (/).
Returns:
the JDOM element corresponding to the root of file, or null if the file did not exist.

loadFromClassPath

public static Element loadFromClassPath(String filename)
            throws IOException
Parameters:
filename - Filename relative to the root of the class path, must not start with a slash (/).
Returns:
the JDOM element corresponding to the root of file, or null if the file did not exist.

loadFromInputStream

public static Element loadFromInputStream(InputStream stream)
            throws JDOMException,
                   IOException
Converts the given XML on the input stream into a JDOM element with all external entities (mainly DTDs) searched for in the package org.grinvin.dtds, but resolved by the class loader of this class.
Parameters:
stream - InputStream containing the XML code.
Returns:
the JDOM element corresponding to the root of the XML.

loadFromInputStreamNonValidating

public static Element loadFromInputStreamNonValidating(InputStream stream)
            throws JDOMException,
                   IOException