Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[hyades-dev] New JDK 1.4 XML utilities.



For those interested, I have written some public utility APIs for working
with XML DOMs/documents which only require JDK 1.4.  These APIs are in the
org.eclipse.hyades.logging.core.XmlUtility in the
org.eclipse.hyades.logging.core plugin.  Please feel free to use these APIs
if your plugin requires the org.eclipse.hyades.logging.core plugin and you
would like to remove Apache dependancies.  Here is a list of the APIs:

    /**
     * Serializes a DOM to an XML document and writes the XML document to
an
     * output file on the local file system .
     * <p>
     * The parameter DOM is serialized to an XML document, which formatted
(e.g.
     * line breaks, indentation, etc.) and written to an output file on the
local
     * file system.
     * <p>
     * The encoding for the serialized XML document is explicitly set to
"UTF-8"
     * for all platforms excluding z/OS and OS/390 platforms. The encoding
for the
     * serialized XML document is explicitly set to "IBM-1047" for z/OS and
OS/390
     * platforms only.
     * <p>
     *
     * @param document The DOM to be serialized to a formatted XML document
and written to the output file.
     * @param outputFile The file on the local file system where the
formatted XML document is written.
     * @throws TransformerException If the <code>TransformerFactory</code>
cannot create a new XML <code>Transformer</code> instance or an error
occurs during                             serialization.
     */
    public static void serialize(Document document, File outputFile) throws
TransformerException

    /**
     * Serializes a DOM to an XML document and writes the XML document to
an
     * output file on the local file system .
     * <p>
     * The parameter DOM is serialized to an XML document, which may be
potentially
     * formatted and written to an output file on the local file system.
     * <p>
     * The serialized XML document is formatted (e.g. line breaks,
indentation,
     * etc.) if the parameter <code>format</code> flag is true.
     * <p>
     * The encoding for the serialized XML document is explicitly set to
"UTF-8"
     * for all platforms excluding z/OS and OS/390 platforms. The encoding
for the
     * serialized XML document is explicitly set to "IBM-1047" for z/OS and
OS/390
     * platforms only.
     * <p>
     *
     * @param document The DOM to be serialized to a potentially formatted
XML document and written to the output file.
     * @param outputFile The file on the local file system where the
potentially formatted XML document is written.
     * @param format If the serialized XML document is formatted (e.g. line
breaks, indentation, etc.).
     * @throws TransformerException If the <code>TransformerFactory</code>
cannot create a new XML <code>Transformer</code> instance or an error
occurs during                       serialization.
     */
    public static void serialize(Document document, File outputFile,
boolean format) throws TransformerException

    /**
     * Serializes a DOM to an XML document string.
     * <p>
     * The parameter DOM is serialized to the returned XML document string,
which is
     * formatted (e.g. line breaks, indentation, etc.).
     * <p>
     * The encoding for the serialized XML document string is explicitly
set to "UTF-8"
     * for all platforms excluding z/OS and OS/390 platforms. The encoding
for the
     * serialized XML document string is explicitly set to "IBM-1047" for
z/OS and OS/390
     * platforms only.
     * <p>
     *
     * @param document The DOM to be serialized to a formatted XML document
string.
     * @return The DOM serialized as a formatted XML document string,
otherwise null.
     * @throws TransformerException If the <code>TransformerFactory</code>
cannot create a new XML <code>Transformer</code> instance or an error
occurs during                       serialization.
     */
    public static String serialize(Document document) throws
TransformerException

    /**
     * Serializes a DOM to an XML document string.
     * <p>
     * The parameter DOM is serialized to the returned XML document string,
     * which may be potentially formatted.
     * <p>
     * The returned XML document string is formatted (e.g. line breaks,
indentation,
     * etc.) if the parameter <code>format</code> flag is true.
     * <p>
     * The encoding for the serialized XML document string is explicitly
set to "UTF-8"
     * for all platforms excluding z/OS and OS/390 platforms. The encoding
for the
     * serialized XML document string is explicitly set to "IBM-1047" for
z/OS and OS/390
     * platforms only.
     * <p>
     *
     * @param document The DOM to be serialized to a potentially formatted
XML document string.
     * @param format If the serialized XML document string is formatted
(e.g. line breaks, indentation, etc.).
     * @return The DOM serialized as a potentially formatted XML document
string, otherwise null.
     * @throws TransformerException If the <code>TransformerFactory</code>
cannot create a new XML <code>Transformer</code> instance or an error
occurs during                       serialization.
     */
    public static String serialize(Document document, boolean format)
throws TransformerException

    /**
     * Normalizes the parameter string according to the XML specification
for
     * attribute-value normalization ( <a
     * href="http://www.w3.org/TR/REC-xml";>http://www.w3.org/TR/REC-xml
</a>)
     * and valid characters ( <a
     * href="http://www.w3.org/TR/REC-
xml#charsets">http://www.w3.org/TR/REC-xml#charsets
     * </a>).
     * <p>
     * Valid characters, according to the XML specification, in all Unicode
     * characters, excluding the surrogate blocks, 0xFFFE, and 0xFFFF.
     * <p>
     *
     * @param string The string to be normalized.
     * @return The normalized string.
     */
    public static String normalize(String string)

    /**
     * Denormalizes the parameter string.
     * <p>
     *
     * @param string The String to be denormalized.
     * @return The denormalized String.
     */
    public static String denormalize(String string)

PS

----------------------------------------------
Paul Slauenwhite
IBM Toronto Lab, Canada

Internet: paules@xxxxxxxxxx
Telephone: (905) 413-3861
Tie Line: 969-3861
Fax: (905) 413-4920
---------------------------------------------



Back to the top