Interface DomDocument
-
- All Known Implementing Classes:
DomDocumentImpl
public interface DomDocument
Encapsulates aDocument
. Implementations of this interface must be thread-safe.- Author:
- Sebastian Menski
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DomDocument
clone()
Clones the DOM document.DomElement
createElement(String namespaceUri, String localName)
Creates a new element in the dom document.DOMSource
getDomSource()
Returns a newDOMSource
of the document.DomElement
getElementById(String id)
Gets an element by its id.List<DomElement>
getElementsByNameNs(String namespaceUri, String localName)
Gets all elements with the namespace and name.DomElement
getRootElement()
Returns the root element of the document.String
registerNamespace(String namespaceUri)
Registers a new namespace with a generic prefix.void
registerNamespace(String prefix, String namespaceUri)
Registers a new namespace for the prefix.void
setRootElement(DomElement rootElement)
Sets the root element of the DOM document.
-
-
-
Method Detail
-
getRootElement
DomElement getRootElement()
Returns the root element of the document.- Returns:
- the root element or null if non exists
-
setRootElement
void setRootElement(DomElement rootElement)
Sets the root element of the DOM document. Replace an existing if necessary.- Parameters:
rootElement
- the new root element
-
createElement
DomElement createElement(String namespaceUri, String localName)
Creates a new element in the dom document.- Parameters:
namespaceUri
- the namespaceUri of the new elementlocalName
- the localName of the new element- Returns:
- the new DOM element
-
getElementById
DomElement getElementById(String id)
Gets an element by its id.- Parameters:
id
- the id to search for- Returns:
- the element or null if no such element exists
-
getElementsByNameNs
List<DomElement> getElementsByNameNs(String namespaceUri, String localName)
Gets all elements with the namespace and name.- Parameters:
namespaceUri
- the element namespaceURI to search forlocalName
- the element name to search for- Returns:
- the list of matching elements
-
getDomSource
DOMSource getDomSource()
Returns a newDOMSource
of the document. Note that aDOMSource
wraps the underlyingDocument
which is not thread-safe. Multiple DOMSources of the same document should be synchronized by the calling application.- Returns:
- the new
DOMSource
-
registerNamespace
String registerNamespace(String namespaceUri)
Registers a new namespace with a generic prefix.- Parameters:
namespaceUri
- the namespaceUri of the new namespace- Returns:
- the used prefix
-
registerNamespace
void registerNamespace(String prefix, String namespaceUri)
Registers a new namespace for the prefix.- Parameters:
prefix
- the prefix of the new namespacenamespaceUri
- the namespaceUri of the new namespace
-
clone
DomDocument clone()
Clones the DOM document.- Returns:
- the cloned DOM document
-
-