edu.ucsb.adl.middleware
Class XmlUtils

java.lang.Object
  |
  +--edu.ucsb.adl.middleware.XmlUtils

public final class XmlUtils
extends java.lang.Object

XML-related utilities.

Version:
$Header: /export/home/gjanee/middleware/edu/ucsb/adl/middleware/RCS/XmlUtils.java,v 1.3 2004/09/22 00:54:56 gjanee Exp $

$Log: XmlUtils.java,v $ Revision 1.3 2004/09/22 00:54:56 gjanee
Added the encode methods.

Revision 1.2 2003/06/07 03:36:49 gjanee
Added method removeProlog.

Revision 1.1 2003/05/12 16:32:54 gjanee
Initial revision

Author:
Greg Janée
Alexandria Digital Library

Method Summary
static java.lang.String encode(java.lang.String s)
          Encodes XML/HTML reserved characters in a string, not including double-quotes (").
static java.lang.String encodeQuotesToo(java.lang.String s)
          Encodes XML/HTML reserved characters in a string, including double-quotes (").
static java.lang.String removeEncodingDeclaration(java.lang.String document)
          Removes the character encoding declaration from an XML document.
static java.lang.String removeProlog(java.lang.String document, java.lang.String rootElement)
          Removes the prolog from an XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

removeEncodingDeclaration

public static java.lang.String removeEncodingDeclaration(java.lang.String document)
Removes the character encoding declaration from an XML document. If there is no declaration, or if an error occurs in finding or removing the declaration, the document is returned unmodified.

Parameters:
document - An XML document.
Returns:
The same document, sans encoding declaration.

removeProlog

public static java.lang.String removeProlog(java.lang.String document,
                                            java.lang.String rootElement)
Removes the prolog from an XML document. If any error occurs, the document is returned unmodified.

Parameters:
document - An XML document.
rootElement - The document's root element (e.g., "ADL-access-report") or null.
Returns:
The same document, sans prolog.

encode

public static java.lang.String encode(java.lang.String s)
Encodes XML/HTML reserved characters in a string, not including double-quotes (").

Parameters:
s - The input string.
Returns:
The same string, encoded.

encodeQuotesToo

public static java.lang.String encodeQuotesToo(java.lang.String s)
Encodes XML/HTML reserved characters in a string, including double-quotes (").

Parameters:
s - The input string.
Returns:
The same string, encoded.