Package org.eclipse.lemminx.dom

## Class DOMDocument

- java.lang.Object
- - org.eclipse.lemminx.dom.DOMNode
  - - org.eclipse.lemminx.dom.DOMDocument

All Implemented Interfaces:
  `DOMRange`, `Document`, `Node`

    public class DOMDocument
    extends DOMNode
    implements Document

XML document.

### Field Summary

### Fields inherited from class org.eclipse.lemminx.dom.DOMNode

`DTD_ATT_LIST_NODE, DTD_DECL_NODE, DTD_ELEMENT_DECL_NODE, DTD_ENTITY_DECL_NODE, DTD_NOTATION_DECL, NULL_VALUE`

### Fields inherited from interface org.w3c.dom.Node

`ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE`

### Constructor Summary

Constructors
`DOMDocument​(TextDocument textDocument, URIResolverExtensionManager resolverExtensionManager)`

### Method Summary

All Methods Instance Methods Concrete Methods
`DOMNode` `adoptNode​(Node source)`
`DOMAttr` `createAttribute​(String name)`
`DOMAttr` `createAttributeNS​(String namespaceURI, String qualifiedName)`
`DOMCDATASection` `createCDataSection​(int start, int end)`
`CDATASection` `createCDATASection​(String data)`
`DOMComment` `createComment​(int start, int end)`
`DOMComment` `createComment​(String data)`
`DocumentFragment` `createDocumentFragment()`
`DOMDocumentType` `createDocumentType​(int start, int end)`
`DOMElement` `createElement​(int start, int end)`
`DOMElement` `createElement​(String tagName)`
`DOMElement` `createElementNS​(String namespaceURI, String qualifiedName)`
`EntityReference` `createEntityReference​(String name)`
`DOMProcessingInstruction` `createProcessingInstruction​(int start, int end)`
`DOMProcessingInstruction` `createProcessingInstruction​(String target, String data)`
`DOMText` `createText​(int start, int end)`
`DOMText` `createTextNode​(String data)`
`Collection<DOMNode>` `findDTDAttrList​(String elementName)` Returns the DTD Attribute list for the given element name and empty otherwise.
`org.eclipse.lsp4j.jsonrpc.CancelChecker` `getCancelChecker()`
`DOMDocumentType` `getDoctype()`
`DOMElement` `getDocumentElement()`
`String` `getDocumentURI()`
`DOMConfiguration` `getDomConfig()`
`DOMElement` `getElementById​(String elementId)`
`org.eclipse.lsp4j.Range` `getElementNameRangeAt​(int textOffset)` Returns the element name on the left of the given position and null otherwise.
`NodeList` `getElementsByTagName​(String tagname)`
`NodeList` `getElementsByTagNameNS​(String namespaceURI, String localName)`
`String` `getExternalGrammarFromNamespaceURI()` Returns the grammar location found by the namespace URI from the document root element (ex : found with XML catalog) and null otherwise.
`Map<String,​String>` `getExternalGrammarLocation()` Returns the external grammar location (XSD, DTD from xml file associations) and null otherwise.
`DOMImplementation` `getImplementation()`
`String` `getInputEncoding()`
`LineIndentInfo` `getLineIndentInfo​(int lineNumber)`
`String` `getNamespaceURI()`
`String` `getNodeName()`
`short` `getNodeType()`
`NoNamespaceSchemaLocation` `getNoNamespaceSchemaLocation()` Returns the declared "xsi:noNamespaceSchemaLocation" and null otherwise.
`DOMDocument` `getOwnerDocument()` Returns the owner document and null otherwise.
`DOMNode` `getProlog()` If document has `<?xml ... ?>`, return this prolog, null otherwise
`URIResolverExtensionManager` `getResolverExtensionManager()`
`List<DOMNode>` `getRoots()`
`String` `getSchemaInstancePrefix()` Returns the (xsi) schema instance prefix and null otherwise.
`SchemaLocation` `getSchemaLocation()` Returns the declared "xsi:schemaLocation" and null otherwise.
`String` `getSchemaPrefix()` Returns the XML Schema prefix (ex : 'xs' for xmlns:xs="http://www.w3.org/2001/XMLSchema")
`boolean` `getStrictErrorChecking()`
`String` `getText()` Returns the text content of the XML document.
`TextDocument` `getTextDocument()`
`org.eclipse.lsp4j.Range` `getTrimmedRange​(int start, int end)`
`org.eclipse.lsp4j.Range` `getTrimmedRange​(org.eclipse.lsp4j.Range range)`
`String` `getXmlEncoding()`
`List<XMLModel>` `getXMLModels()` Returns the list of xml-model processing instruction declared in the document.
`boolean` `getXmlStandalone()`
`String` `getXmlVersion()`
`boolean` `hasDTD()` Returns true if XML document has a DTD declaration and false otherwise.
`boolean` `hasExternalGrammar()` Returns true if the document is bound to an external grammar (XML file associations, XLM catalog) and false otherwise.
`boolean` `hasGrammar()` Returns true if the document is bound to a grammar and false otherwise.
`boolean` `hasNamespaces()` Returns true if document defines namespaces (with xmlns) and false otherwise.
`boolean` `hasNoNamespaceSchemaLocation()` Returns true if XML root element declares a "xsi:noNamespaceSchemaLocation" and false otherwise.
`boolean` `hasProlog()` If document has `<?xml ... ?>`
`boolean` `hasSchemaInstancePrefix()` Returns true if (xsi) schema instance prefix exists.
`boolean` `hasSchemaLocation()` Returns true if XML root element declares a "xsi:schemaLocation" and false otherwise.
`boolean` `hasXMLModel()` Returns true if XML document has a xml-model processing declaration and false otherwise.
`DOMNode` `importNode​(Node importedNode, boolean deep)`
`boolean` `isBeforeProlog​(int offset)` Returns true, if the given offset is before XML declaration (`<?xml ...?>`), false otherwise.
`boolean` `isDTD()` Returns true if the XML document is a DTD and false otherwise.
`boolean` `isWithinInternalDTD​(int offset)` Returns true if 'offset' is within an internal DOCTYPE dtd.
`String` `lineDelimiter​(int lineNumber)`
`String` `lineText​(int lineNumber)`
`void` `normalizeDocument()`
`int` `offsetAt​(org.eclipse.lsp4j.Position position)`
`org.eclipse.lsp4j.Position` `positionAt​(int offset)`
`DOMNode` `renameNode​(Node n, String namespaceURI, String qualifiedName)`
`void` `resetGrammar()` Reset the cached grammar flag.
`void` `setCancelChecker​(org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)`
`void` `setDocumentURI​(String documentURI)`
`void` `setStrictErrorChecking​(boolean strictErrorChecking)`
`void` `setXmlStandalone​(boolean xmlStandalone)`
`void` `setXmlVersion​(String xmlVersion)`

### Methods inherited from class org.eclipse.lemminx.dom.DOMNode

`addChild, appendChild, cloneNode, compareDocumentPosition, findAttrAt, findAttrAt, findDTDDeclParameterAt, findDTDDeclParameterAt, findNodeAt, findNodeBefore, findNodeOrAttrAt, findTextAt, getAttribute, getAttributeAtIndex, getAttributeNode, getAttributeNode, getAttributeNodes, getAttributes, getBaseURI, getChild, getChildNodes, getChildren, getChildrenWithAttributeValue, getEnd, getFeature, getFirstChild, getLastChild, getLocalName, getNextSibling, getNodeValue, getOrphanEndElement, getOrphanEndElement, getParentElement, getParentNode, getPrefix, getPreviousNonTextSibling, getPreviousSibling, getStart, getTextContent, getUserData, hasAttribute, hasAttributes, hasChildNodes, insertBefore, isAttribute, isCDATA, isCharacterData, isChildOfOwnerDocument, isClosed, isComment, isDefaultNamespace, isDoctype, isDTDAttListDecl, isDTDElementDecl, isDTDEntityDecl, isDTDNotationDecl, isElement, isEqualNode, isGenericDTDDecl, isIncluded, isIncluded, isOwnerDocument, isProcessingInstruction, isProlog, isSameNode, isSupported, isText, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setAttribute, setAttributeNode, setNodeValue, setPrefix, setTextContent, setUserData, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.w3c.dom.Node

`appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData`

### Constructor Detail

#### DOMDocument

    public DOMDocument​(TextDocument textDocument,
                       URIResolverExtensionManager resolverExtensionManager)

### Method Detail

#### setCancelChecker

    public void setCancelChecker​(org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)

#### getCancelChecker

    public org.eclipse.lsp4j.jsonrpc.CancelChecker getCancelChecker()

#### getRoots

    public List<DOMNode> getRoots()

#### positionAt

    public org.eclipse.lsp4j.Position positionAt​(int offset)
                                          throws BadLocationException

Throws:
  `BadLocationException`

#### offsetAt

    public int offsetAt​(org.eclipse.lsp4j.Position position)
                 throws BadLocationException

Throws:
  `BadLocationException`

#### lineText

    public String lineText​(int lineNumber)
                    throws BadLocationException

Throws:
  `BadLocationException`

#### lineDelimiter

    public String lineDelimiter​(int lineNumber)
                         throws BadLocationException

Throws:
  `BadLocationException`

#### getLineIndentInfo

    public LineIndentInfo getLineIndentInfo​(int lineNumber)
                                     throws BadLocationException

Throws:
  `BadLocationException`

#### getElementNameRangeAt

    public org.eclipse.lsp4j.Range getElementNameRangeAt​(int textOffset)

Returns the element name on the left of the given position and null otherwise.

Parameters:
  `textOffset` -
Returns:
  the element name on the left of the given position and null otherwise.

#### getNamespaceURI

    public String getNamespaceURI()

Specified by:
  `getNamespaceURI` in interface `Node`
Overrides:
  `getNamespaceURI` in class `DOMNode`

#### getText

    public String getText()

Returns the text content of the XML document.

Returns:
  the text content of the XML document.

#### getTextDocument

    public TextDocument getTextDocument()

#### hasGrammar

    public boolean hasGrammar()

Returns true if the document is bound to a grammar and false otherwise.

Returns:
  true if the document is bound to a grammar and false otherwise.

#### getSchemaLocation

    public SchemaLocation getSchemaLocation()

Returns the declared "xsi:schemaLocation" and null otherwise.

Returns:
  the declared "xsi:schemaLocation" and null otherwise.

#### hasSchemaLocation

    public boolean hasSchemaLocation()

Returns true if XML root element declares a "xsi:schemaLocation" and false otherwise.

Returns:
  true if XML root element declares a "xsi:schemaLocation" and false otherwise.

#### getNoNamespaceSchemaLocation

    public NoNamespaceSchemaLocation getNoNamespaceSchemaLocation()

Returns the declared "xsi:noNamespaceSchemaLocation" and null otherwise.

Returns:
  the declared "xsi:noNamespaceSchemaLocation" and null otherwise.

#### hasNoNamespaceSchemaLocation

    public boolean hasNoNamespaceSchemaLocation()

Returns true if XML root element declares a "xsi:noNamespaceSchemaLocation" and false otherwise.

Returns:
  true if XML root element declares a "xsi:noNamespaceSchemaLocation" and false otherwise.

#### hasNamespaces

    public boolean hasNamespaces()

Returns true if document defines namespaces (with xmlns) and false otherwise.

Returns:
  true if document defines namespaces (with xmlns) and false otherwise.

#### getSchemaInstancePrefix

    public String getSchemaInstancePrefix()

Returns the (xsi) schema instance prefix and null otherwise.

Returns:
  the (xsi) schema instance prefix and null otherwise.

#### hasSchemaInstancePrefix

    public boolean hasSchemaInstancePrefix()

Returns true if (xsi) schema instance prefix exists.

Returns:
  true if (xsi) schema instance prefix exists.

#### hasProlog

    public boolean hasProlog()

If document has `<?xml ... ?>`

Returns:

#### getProlog

    public DOMNode getProlog()

If document has `<?xml ... ?>`, return this prolog, null otherwise

Returns:
  prolog DOMNode, if the document has one, null otherwise

#### isBeforeProlog

    public boolean isBeforeProlog​(int offset)

Returns true, if the given offset is before XML declaration (`<?xml ...?>`), false otherwise.

Parameters:
  `offset` - the offset position in question
Returns:
  true, if before xml declaration; false otherwise

#### hasDTD

    public boolean hasDTD()

Returns true if XML document has a DTD declaration and false otherwise.

Returns:
  true if XML document has a DTD declaration and false otherwise.

#### hasXMLModel

    public boolean hasXMLModel()

Returns true if XML document has a xml-model processing declaration and false otherwise.

Returns:
  true if XML document has a xml-model processing declaration and false otherwise.

#### getXMLModels

    public List<XMLModel> getXMLModels()

Returns the list of xml-model processing instruction declared in the document.

Returns:
  the list of xml-model processing instruction declared in the document.

#### hasExternalGrammar

    public boolean hasExternalGrammar()

Returns true if the document is bound to an external grammar (XML file associations, XLM catalog) and false otherwise.

Returns:
  true if the document is bound to an external grammar (XML file associations, XLM catalog) and false otherwise.

#### getExternalGrammarLocation

    public Map<String,​String> getExternalGrammarLocation()

Returns the external grammar location (XSD, DTD from xml file associations) and null otherwise.

Returns:
  the external grammar location (XSD, DTD from xml file associations) and null otherwise.

#### getExternalGrammarFromNamespaceURI

    public String getExternalGrammarFromNamespaceURI()

Returns the grammar location found by the namespace URI from the document root element (ex : found with XML catalog) and null otherwise.

Returns:
  the grammar location found by the namespace URI from the document root element (ex : found with XML catalog) and null otherwise.

#### createElement

    public DOMElement createElement​(int start,
                                    int end)

#### createCDataSection

    public DOMCDATASection createCDataSection​(int start,
                                              int end)

#### createProcessingInstruction

    public DOMProcessingInstruction createProcessingInstruction​(int start,
                                                                int end)

#### createComment

    public DOMComment createComment​(int start,
                                    int end)

#### createText

    public DOMText createText​(int start,
                              int end)

#### createDocumentType

    public DOMDocumentType createDocumentType​(int start,
                                              int end)

#### getNodeType

    public short getNodeType()

Specified by:
  `getNodeType` in interface `Node`

#### getNodeName

    public String getNodeName()

Specified by:
  `getNodeName` in interface `Node`

#### getDocumentElement

    public DOMElement getDocumentElement()

Specified by:
  `getDocumentElement` in interface `Document`

#### getDoctype

    public DOMDocumentType getDoctype()

Specified by:
  `getDoctype` in interface `Document`

#### getOwnerDocument

    public DOMDocument getOwnerDocument()

Description copied from class: `DOMNode`
Returns the owner document and null otherwise.

Specified by:
  `getOwnerDocument` in interface `DOMRange`
Specified by:
  `getOwnerDocument` in interface `Node`
Overrides:
  `getOwnerDocument` in class `DOMNode`
Returns:
  the owner document and null otherwise.

#### getDocumentURI

    public String getDocumentURI()

Specified by:
  `getDocumentURI` in interface `Document`

#### setDocumentURI

    public void setDocumentURI​(String documentURI)

Specified by:
  `setDocumentURI` in interface `Document`

#### adoptNode

    public DOMNode adoptNode​(Node source)
                      throws DOMException

Specified by:
  `adoptNode` in interface `Document`
Throws:
  `DOMException`

#### createAttribute

    public DOMAttr createAttribute​(String name)
                            throws DOMException

Specified by:
  `createAttribute` in interface `Document`
Throws:
  `DOMException`

#### createAttributeNS

    public DOMAttr createAttributeNS​(String namespaceURI,
                                     String qualifiedName)
                              throws DOMException

Specified by:
  `createAttributeNS` in interface `Document`
Throws:
  `DOMException`

#### createCDATASection

    public CDATASection createCDATASection​(String data)
                                    throws DOMException

Specified by:
  `createCDATASection` in interface `Document`
Throws:
  `DOMException`

#### createComment

    public DOMComment createComment​(String data)

Specified by:
  `createComment` in interface `Document`

#### createDocumentFragment

    public DocumentFragment createDocumentFragment()

Specified by:
  `createDocumentFragment` in interface `Document`

#### createElement

    public DOMElement createElement​(String tagName)
                             throws DOMException

Specified by:
  `createElement` in interface `Document`
Throws:
  `DOMException`

#### createElementNS

    public DOMElement createElementNS​(String namespaceURI,
                                      String qualifiedName)
                               throws DOMException

Specified by:
  `createElementNS` in interface `Document`
Throws:
  `DOMException`

#### createEntityReference

    public EntityReference createEntityReference​(String name)
                                          throws DOMException

Specified by:
  `createEntityReference` in interface `Document`
Throws:
  `DOMException`

#### createProcessingInstruction

    public DOMProcessingInstruction createProcessingInstruction​(String target,
                                                                String data)
                                                         throws DOMException

Specified by:
  `createProcessingInstruction` in interface `Document`
Throws:
  `DOMException`

#### createTextNode

    public DOMText createTextNode​(String data)

Specified by:
  `createTextNode` in interface `Document`

#### getDomConfig

    public DOMConfiguration getDomConfig()

Specified by:
  `getDomConfig` in interface `Document`

#### getElementById

    public DOMElement getElementById​(String elementId)

Specified by:
  `getElementById` in interface `Document`

#### getElementsByTagName

    public NodeList getElementsByTagName​(String tagname)

Specified by:
  `getElementsByTagName` in interface `Document`

#### getElementsByTagNameNS

    public NodeList getElementsByTagNameNS​(String namespaceURI,
                                           String localName)

Specified by:
  `getElementsByTagNameNS` in interface `Document`

#### getImplementation

    public DOMImplementation getImplementation()

Specified by:
  `getImplementation` in interface `Document`

#### getInputEncoding

    public String getInputEncoding()

Specified by:
  `getInputEncoding` in interface `Document`

#### getStrictErrorChecking

    public boolean getStrictErrorChecking()

Specified by:
  `getStrictErrorChecking` in interface `Document`

#### getXmlEncoding

    public String getXmlEncoding()

Specified by:
  `getXmlEncoding` in interface `Document`

#### getXmlStandalone

    public boolean getXmlStandalone()

Specified by:
  `getXmlStandalone` in interface `Document`

#### getXmlVersion

    public String getXmlVersion()

Specified by:
  `getXmlVersion` in interface `Document`

#### importNode

    public DOMNode importNode​(Node importedNode,
                              boolean deep)
                       throws DOMException

Specified by:
  `importNode` in interface `Document`
Throws:
  `DOMException`

#### normalizeDocument

    public void normalizeDocument()

Specified by:
  `normalizeDocument` in interface `Document`

#### renameNode

    public DOMNode renameNode​(Node n,
                              String namespaceURI,
                              String qualifiedName)
                       throws DOMException

Specified by:
  `renameNode` in interface `Document`
Throws:
  `DOMException`

#### setStrictErrorChecking

    public void setStrictErrorChecking​(boolean strictErrorChecking)

Specified by:
  `setStrictErrorChecking` in interface `Document`

#### setXmlStandalone

    public void setXmlStandalone​(boolean xmlStandalone)
                          throws DOMException

Specified by:
  `setXmlStandalone` in interface `Document`
Throws:
  `DOMException`

#### setXmlVersion

    public void setXmlVersion​(String xmlVersion)
                       throws DOMException

Specified by:
  `setXmlVersion` in interface `Document`
Throws:
  `DOMException`

#### resetGrammar

    public void resetGrammar()

Reset the cached grammar flag.

#### getResolverExtensionManager

    public URIResolverExtensionManager getResolverExtensionManager()

#### isDTD

    public boolean isDTD()

Returns true if the XML document is a DTD and false otherwise.

Returns:
  true if the XML document is a DTD and false otherwise.

#### isWithinInternalDTD

    public boolean isWithinInternalDTD​(int offset)

Returns true if 'offset' is within an internal DOCTYPE dtd. Else false.

Parameters:
  `offset` -
Returns:

#### getTrimmedRange

    public org.eclipse.lsp4j.Range getTrimmedRange​(org.eclipse.lsp4j.Range range)

#### getTrimmedRange

    public org.eclipse.lsp4j.Range getTrimmedRange​(int start,
                                                   int end)

#### findDTDAttrList

    public Collection<DOMNode> findDTDAttrList​(String elementName)

Returns the DTD Attribute list for the given element name and empty otherwise.

Parameters:
  `elementName` -
Returns:
  the DTD Attribute list for the given element name and empty otherwise.

#### getSchemaPrefix

    public String getSchemaPrefix()

Returns the XML Schema prefix (ex : 'xs' for xmlns:xs="http://www.w3.org/2001/XMLSchema")

Returns:
  the XML Schema prefix (ex : 'xs' for xmlns:xs="http://www.w3.org/2001/XMLSchema")