com.partnersoft.io.formats.xml
Class XMLLib

java.lang.Object
  extended by com.partnersoft.io.formats.xml.XMLLib

public class XMLLib
extends java.lang.Object

Useful XMLish functions.

RDC: added a bunch of DOM functions.

Author:
Paul Reavis Copyright 2003 Partner Software, Inc.

Constructor Summary
XMLLib()
           
 
Method Summary
static org.w3c.dom.Document createDocument(org.w3c.dom.Node document)
          Creates a new document with a copy of the given element as the document element.
static java.lang.String escapeAttribute(java.lang.String original)
          Replaces reserved XML characters with entity references.
static java.lang.String escapeContent(java.lang.String original)
          Replaces reserved XML characters with entity references.
static java.lang.String escapeString(java.lang.String original)
           
static boolean isAnscestor(org.w3c.dom.Node parentToCheck, org.w3c.dom.Node child)
           
static void logNode(org.w3c.dom.Node node)
          Writes the node out to the log.
static org.w3c.dom.Document open(java.io.File file)
           
static org.w3c.dom.Document open(java.io.InputStream instr)
           
static org.w3c.dom.Document open(java.lang.String filename)
           
static java.lang.String unescape(java.lang.String original)
          Replaces entity references for XML reserved characters with their character form.
static void write(org.w3c.dom.Node document, java.io.File file)
          Writes document as the document element of a new document.
static void write(org.w3c.dom.Node document, java.lang.String filename)
          Writes document as the document element of a new document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLLib

public XMLLib()
Method Detail

escapeString

public static java.lang.String escapeString(java.lang.String original)

escapeContent

public static java.lang.String escapeContent(java.lang.String original)
Replaces reserved XML characters with entity references. The result is then safe to store as XML content.

Currently replaces the following:


escapeAttribute

public static java.lang.String escapeAttribute(java.lang.String original)
Replaces reserved XML characters with entity references. The result is then safe to store as an XML content attribute value.

Currently replaces the following:


unescape

public static java.lang.String unescape(java.lang.String original)
Replaces entity references for XML reserved characters with their character form. Reverses all the substitutions performed by escapeContent() and escapeAttribute().


open

public static org.w3c.dom.Document open(java.lang.String filename)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

open

public static org.w3c.dom.Document open(java.io.File file)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

open

public static org.w3c.dom.Document open(java.io.InputStream instr)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

write

public static void write(org.w3c.dom.Node document,
                         java.lang.String filename)
                  throws java.lang.Exception
Writes document as the document element of a new document. Document document document.

Throws:
java.lang.Exception

write

public static void write(org.w3c.dom.Node document,
                         java.io.File file)
                  throws java.lang.Exception
Writes document as the document element of a new document. Document document document.

Throws:
java.lang.Exception

createDocument

public static org.w3c.dom.Document createDocument(org.w3c.dom.Node document)
Creates a new document with a copy of the given element as the document element.


logNode

public static void logNode(org.w3c.dom.Node node)
                    throws java.lang.Exception
Writes the node out to the log. TODO - doesn't actually do that. How can you write a Node to a log4j Logger?

Throws:
java.lang.Exception

isAnscestor

public static boolean isAnscestor(org.w3c.dom.Node parentToCheck,
                                  org.w3c.dom.Node child)