org.brownell.xml
Class DomFactory

java.lang.Object
  |
  +--org.brownell.xml.DomFactory

public class DomFactory
extends java.lang.Object

Instantiates a DOMImplementation object, according to system defaults or a user-specified implementation choice. When used with the current DOM Level 2 specification, this means that Java applications have a completely portable mechanism way to create empty DOM documents. This is one of the two basic ways that DOM documents are normally used. Any vendor-specific issues may be encapsulated through changes to the implementation of one static method.

A separate mechanism is still required to connect a DOM implementation to an XML or HTML processor ("parser"), producing a document which is not empty but rather is populated with results of parsing a document. In this package the DomBuilder class solves that problem for SAX parsers. (In the future these two mechanisms might be integrated in one class, once it is possible to use a single configuration mechanism to address both issues.)

Also, because DOM includes APIs that provide read-only access to some facilities without including the capability to write them, some parts of DOM still remain accessible only through use of proprietary APIs. Much DTD-related functionality is so constrained.

Version:
$Date: 2000/02/20 18:42:46 $
Author:
David Brownell
See Also:
DomBuilder

Method Summary
static org.w3c.dom.DOMImplementation createDom()
          Access the system default DOM implementation.
static org.w3c.dom.DOMImplementation createDom(java.lang.String className)
          Create a new DOM implementation object using the class name provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createDom

public static org.w3c.dom.DOMImplementation createDom()
                                               throws java.lang.reflect.InvocationTargetException

Access the system default DOM implementation. The actual implementation of this method may vary between implementations of the DOM, but the interface is not subject to change.

The reference implementation of this class works with all DOM implementations which can be accessed using only a default constructor. The class name may be specified by the org.brownell.xml.dom system property, or by a built-in default if that property is not available. The named class must exist and must implement the org.w3c.dom.DomImplementation interface.

Other implementations of this method are free to use other mechanisms. For example, a browser might both hard-wire some specific implementation, and also arrange that it be initialized to bind the DOM objects to some particular window and an associated rendering engine.

Throws:
java.lang.reflect.InvocationTargetException - No default DOM implementation is available. This may be due to a a variety of underlying errors, reported through the "target exception" property of this exception. These usually involve configuration errors such as incorrect values for a system property, bad class path, or a malfunctioning DOM.
See Also:
createDom(java.lang.String)

createDom

public static org.w3c.dom.DOMImplementation createDom(java.lang.String className)
                                               throws java.lang.reflect.InvocationTargetException
Create a new DOM implementation object using the class name provided. If that class can't be instantiated, or does not implement the org.w3c.dom.DomImplementation interface, an exception is thrown.

No implementation-specific behavior is allowed for this method, unlike its no-arguments cousin which explicitly allows it. This method is only useful for DOM implementations which provide a null constructor which is publicly accessible, which at this writing describes almost all DOM implementations in Java.

Parameters:
className - A string containing the name of the class implementing the DomImplementation interface.
Throws:
java.lang.reflect.InvocationTargetException - No default DOM implementation is available. This may be due to a a variety of underlying errors, reported through the "target exception" property of this exception. These usually involve configuration errors such as incorrect values for a system property, bad class path, or a malfunctioning DOM.
See Also:
createDom()