org.dom4j

Interface Document

public interface Document extends Branch

Document defines an XML Document.

Version: $Revision: 1.14 $

Author: James Strachan

Method Summary
DocumentaddComment(String comment)
Adds a new Comment node with the given text to this branch.
DocumentaddDocType(String name, String publicId, String systemId)
Adds a DOCTYPE declaration to this document
DocumentaddProcessingInstruction(String target, String text)
Adds a processing instruction for the given target
DocumentaddProcessingInstruction(String target, Map data)
Adds a processing instruction for the given target
DocumentTypegetDocType()
DOCUMENT ME!
EntityResolvergetEntityResolver()
DOCUMENT ME!
ElementgetRootElement()
Returns the root {@link Element}for this document.
StringgetXMLEncoding()
Return the encoding of this document, as part of the XML declaration This is null when unspecified or when it is not known (such as when the Document was created in memory) or when the implementation does not support this operation.
voidsetDocType(DocumentType docType)
Sets the DocumentType property
voidsetEntityResolver(EntityResolver entityResolver)
Sets the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documents
voidsetRootElement(Element rootElement)
Sets the root element for this document
voidsetXMLEncoding(String encoding)
Sets the encoding of this document as it will appear in the XML declaration part of the document.

Method Detail

addComment

public Document addComment(String comment)
Adds a new Comment node with the given text to this branch.

Parameters: comment is the text for the Comment node.

Returns: this Document instance.

addDocType

public Document addDocType(String name, String publicId, String systemId)
Adds a DOCTYPE declaration to this document

Parameters: name is the name of the root element publicId is the PUBLIC URI systemId is the SYSTEM URI

Returns: this Document instance.

addProcessingInstruction

public Document addProcessingInstruction(String target, String text)
Adds a processing instruction for the given target

Parameters: target is the target of the processing instruction text is the textual data (key/value pairs) of the processing instruction

Returns: this Document instance.

addProcessingInstruction

public Document addProcessingInstruction(String target, Map data)
Adds a processing instruction for the given target

Parameters: target is the target of the processing instruction data is a Map of the key / value pairs of the processing instruction

Returns: this Document instance.

getDocType

public DocumentType getDocType()
DOCUMENT ME!

Returns: the DocumentType property

getEntityResolver

public EntityResolver getEntityResolver()
DOCUMENT ME!

Returns: the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documents

getRootElement

public Element getRootElement()
Returns the root {@link Element}for this document.

Returns: the root element for this document

getXMLEncoding

public String getXMLEncoding()
Return the encoding of this document, as part of the XML declaration This is null when unspecified or when it is not known (such as when the Document was created in memory) or when the implementation does not support this operation.

The way this encoding is retrieved also depends on the way the XML source is parsed. For instance, if the SAXReader is used and if the underlying XMLReader implementation support the org.xml.sax.ext.Locator2 interface, the result returned by this method is specified by the getEncoding() method of that interface.

Returns: The encoding of this document, as stated in the XML declaration, or null if unknown.

Since: 1.5

setDocType

public void setDocType(DocumentType docType)
Sets the DocumentType property

Parameters: docType DOCUMENT ME!

setEntityResolver

public void setEntityResolver(EntityResolver entityResolver)
Sets the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documents

Parameters: entityResolver DOCUMENT ME!

setRootElement

public void setRootElement(Element rootElement)
Sets the root element for this document

Parameters: rootElement the new root element for this document

setXMLEncoding

public void setXMLEncoding(String encoding)
Sets the encoding of this document as it will appear in the XML declaration part of the document.

Parameters: encoding the encoding of the document

Since: 1.6

Copyright B) 2005 MetaStuff Ltd. All Rights Reserved. Hosted by

SourceForge