gnu.xml.libxmlj.dom

Class GnomeDocumentBuilder

Implemented Interfaces:
DOMImplementation

public class GnomeDocumentBuilder
extends DocumentBuilder
implements DOMImplementation

A JAXP DOM implementation that uses Gnome libxml2 as the underlying parser and node representation.

Constructor Summary

GnomeDocumentBuilder()
Constructs a new validating document builder.
GnomeDocumentBuilder(boolean validate, boolean coalesce, boolean expandEntities)
Constructs a new document builder.

Method Summary

Document
createDocument(String namespaceURI, String qualifiedName, DocumentType doctype)
Creates a DOM Document object of the specified type with its document element.
DocumentType
createDocumentType(String qualifiedName, String publicId, String systemId)
Creates an empty DocumentType node.
DOMImplementation
getDOMImplementation()
Returns the DOM implementation.
Object
getFeature(String feature, String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in .
boolean
hasFeature(String name, String version)
Test if the DOM implementation implements a specific feature and version, as specified in .
boolean
isNamespaceAware()
Indicates whether this document builder is XML Namespace aware.
boolean
isValidating()
Indicates whether this document builder will validate its input.
Document
newDocument()
Creates a new, empty DOM Document.
Document
parse(InputSource input)
Parse the specified input source and return a DOM Document.
void
setEntityResolver(EntityResolver resolver)
Sets the SAX entity resolver callback used to resolve external entities in the XML document(s) to parse.
void
setErrorHandler(ErrorHandler handler)
Sets the SAX error handler callback used to report parsing errors.

Methods inherited from class javax.xml.parsers.DocumentBuilder

getDOMImplementation, getSchema, isNamespaceAware, isValidating, isXIncludeAware, newDocument, parse, parse, parse, parse, parse, reset, setEntityResolver, setErrorHandler

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

GnomeDocumentBuilder

public GnomeDocumentBuilder()
Constructs a new validating document builder.

GnomeDocumentBuilder

public GnomeDocumentBuilder(boolean validate,
                            boolean coalesce,
                            boolean expandEntities)
Constructs a new document builder.
Parameters:
validate - whether to validate during parsing
coalesce - whether to merge CDATA as text nodes
expandEntities - whether to expand entity references

Method Details

createDocument

public Document createDocument(String namespaceURI,
                               String qualifiedName,
                               DocumentType doctype)
Creates a DOM Document object of the specified type with its document element.
Note that based on the DocumentType given to create the document, the implementation may instantiate specialized Document objects that support additional features than the "Core", such as "HTML" [DOM Level 2 HTML] . On the other hand, setting the DocumentType after the document was created makes this very unlikely to happen. Alternatively, specialized Document creation methods, such as createHTMLDocument [DOM Level 2 HTML] , can be used to obtain specific types of Document objects.
Specified by:
createDocument in interface DOMImplementation
Parameters:
namespaceURI - The namespace URI of the document element to create or null.
qualifiedName - The qualified name of the document element to be created or null.
doctype - The type of document to be created or null. When doctype is not null, its Node.ownerDocument attribute is set to the document being created.
Returns:
A new Document object with its document element. If the NamespaceURI, qualifiedName, and doctype are null, the returned Document is empty with no document element.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to [XML 1.0].
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName is null and the namespaceURI is different from null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace" [XML Namespaces] , or if the DOM implementation does not support the "XML" feature but a non-null namespace URI was provided, since namespaces were defined by XML.
WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document or was created from a different implementation.
NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).
Since:
DOM Level 2

createDocumentType

public DocumentType createDocumentType(String qualifiedName,
                                       String publicId,
                                       String systemId)
Creates an empty DocumentType node. Entity declarations and notations are not made available. Entity reference expansions and default attribute additions do not occur..
Specified by:
createDocumentType in interface DOMImplementation
Parameters:
qualifiedName - The qualified name of the document type to be created.
publicId - The external subset public identifier.
systemId - The external subset system identifier.
Returns:
A new DocumentType node with Node.ownerDocument set to null.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to [XML 1.0].
NAMESPACE_ERR: Raised if the qualifiedName is malformed.
NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).
Since:
DOM Level 2

getDOMImplementation

public DOMImplementation getDOMImplementation()
Returns the DOM implementation.
Overrides:
getDOMImplementation in interface DocumentBuilder

getFeature

public Object getFeature(String feature,
                         String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in . The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in . This method also allow the implementation to provide specialized objects which do not support the DOMImplementation interface.
Specified by:
getFeature in interface DOMImplementation
Parameters:
feature - The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method.
version - This is the version number of the feature to test.
Returns:
Returns an object which implements the specialized APIs of the specified feature and version, if any, or null if there is no object which implements interfaces associated with that feature. If the DOMObject returned by this method implements the DOMImplementation interface, it must delegate to the primary core DOMImplementation and not return results inconsistent with the primary core DOMImplementation such as hasFeature, getFeature, etc.
Since:
DOM Level 3

hasFeature

public boolean hasFeature(String name,
                          String version)
Test if the DOM implementation implements a specific feature and version, as specified in .
Specified by:
hasFeature in interface DOMImplementation
Parameters:
version - This is the version number of the feature to test.
Returns:
true if the feature is implemented in the specified version, false otherwise.

isNamespaceAware

public boolean isNamespaceAware()
Indicates whether this document builder is XML Namespace aware.
Overrides:
isNamespaceAware in interface DocumentBuilder

isValidating

public boolean isValidating()
Indicates whether this document builder will validate its input.
Overrides:
isValidating in interface DocumentBuilder

newDocument

public Document newDocument()
Creates a new, empty DOM Document. To create a document with a root element and optional doctype, use the DOMImplementation instead.
Overrides:
newDocument in interface DocumentBuilder

parse

public Document parse(InputSource input)
            throws SAXException,
                   IOException
Parse the specified input source and return a DOM Document.
Overrides:
parse in interface DocumentBuilder
Parameters:
Throws:
IllegalArgumentException - if the input source is null

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
Sets the SAX entity resolver callback used to resolve external entities in the XML document(s) to parse.
Overrides:
setEntityResolver in interface DocumentBuilder
Parameters:

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Sets the SAX error handler callback used to report parsing errors.
Overrides:
setErrorHandler in interface DocumentBuilder
Parameters:

GnomeDocumentBuilder.java - Copyright (C) 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.