com.arsdigita.xml
Class Document

java.lang.Object
  extended bycom.arsdigita.xml.Document

public class Document
extends Object

A wrapper class that implements some functionality of org.jdom.Document using org.w3c.dom.Document.

Since:
ACS 4.5a
Version:
ACS 4.5a
Author:
Patrick McNeill

Field Summary
protected  org.w3c.dom.Document m_document
          The internal DOM document being wrapped.
protected static javax.xml.parsers.DocumentBuilderFactory s_builder
          A single DocumentBuilderFactory to use for creating Documents.
protected static ThreadLocal s_db
          A single DocumentBuilder to use for creating Documents.
static String versionId
           
 
Constructor Summary
Document()
          Creates a new Document class with no root element.
Document(byte[] xmlBytes)
           
Document(org.w3c.dom.Document doc)
          Creates a new Document class based on an org.w3c.dom.Document.
Document(Element rootNode)
          Creates a new Document class with the given root element.
Document(String xmlString)
          Creates a document from the passed in string that should be properly formatted XML
 
Method Summary
 Element createRootElement(String elt)
          Creates a new element and sets it as the root.
 Element createRootElement(String elt, String ns)
          Creates a new element and sets it as the root.
 org.w3c.dom.Document getInternalDocument()
          Not a part of org.jdom.Document, this function returns the internal DOM representation of this document.
 Element getRootElement()
          Returns the root element for the document.
 Document setRootElement(Element rootNode)
          Sets the root element.
 String toString()
          Generates an XML text representation of this document, without additional indenting.
 String toString(boolean indent)
          Generates an XML text representation of this document.
static String toString(org.w3c.dom.Document document)
          Convenience wrapper for static toString(Document, boolean), without additional indenting.
static String toString(org.w3c.dom.Document document, boolean indent)
          General toString() method for org.w3c.domDocument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

s_builder

protected static javax.xml.parsers.DocumentBuilderFactory s_builder
A single DocumentBuilderFactory to use for creating Documents.


s_db

protected static ThreadLocal s_db
A single DocumentBuilder to use for creating Documents.


m_document

protected org.w3c.dom.Document m_document
The internal DOM document being wrapped.

Constructor Detail

Document

public Document()
         throws javax.xml.parsers.ParserConfigurationException
Creates a new Document class with no root element.


Document

public Document(org.w3c.dom.Document doc)
Creates a new Document class based on an org.w3c.dom.Document.

Parameters:
doc - the org.w3c.dom.Document

Document

public Document(Element rootNode)
         throws javax.xml.parsers.ParserConfigurationException
Creates a new Document class with the given root element.

Parameters:
rootNode - the element to use as the root node

Document

public Document(String xmlString)
         throws javax.xml.parsers.ParserConfigurationException,
                org.xml.sax.SAXException
Creates a document from the passed in string that should be properly formatted XML


Document

public Document(byte[] xmlBytes)
         throws javax.xml.parsers.ParserConfigurationException,
                org.xml.sax.SAXException
Method Detail

setRootElement

public Document setRootElement(Element rootNode)
Sets the root element.

Parameters:
rootNode - the element to use as the root node
Returns:
this document.

createRootElement

public Element createRootElement(String elt,
                                 String ns)
Creates a new element and sets it as the root. Equivalent to
 Element root = new Element("name", NS);
 doc.setRootElement(root);
 

Parameters:
elt - the element name
ns - the element's namespace URI
Returns:
The newly created root element.

createRootElement

public Element createRootElement(String elt)
Creates a new element and sets it as the root. Equivalent to
 Element root = new Element("name", NS);
 doc.setRootElement(root);
 

Parameters:
elt - the element name
Returns:
The newly created root element.

getRootElement

public Element getRootElement()
Returns the root element for the document. This is the top-level element (the "HTML" element in an HTML document).

Returns:
the document's root element.

getInternalDocument

public org.w3c.dom.Document getInternalDocument()
Not a part of org.jdom.Document, this function returns the internal DOM representation of this document. This method should only be used when passing the DOM to the translator. It will require changes once JDOM replaces this class.

Returns:
this document.

toString

public static String toString(org.w3c.dom.Document document,
                              boolean indent)
General toString() method for org.w3c.domDocument. Not really related to xml.Document, but needed here. Converts an XML in-memory DOM to String representation, using an XSLT identity transformation.

Parameters:
document - the org.w3c.dom.Document object to convert to a String representation
indent - if true, try to indent elements according to normal XML/SGML indentation conventions (may only work with certain XSLT engines)
Returns:
a String representation of document.

toString

public static String toString(org.w3c.dom.Document document)
Convenience wrapper for static toString(Document, boolean), without additional indenting.

Parameters:
document - the org.w3c.dom.Document to output
Returns:
a String representation of document.

toString

public String toString(boolean indent)
Generates an XML text representation of this document.

Parameters:
indent - if true, try to indent XML elements according to XML/SGML convention
Returns:
a String representation of this.

toString

public String toString()
Generates an XML text representation of this document, without additional indenting.

Returns:
a String representation of this.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC