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.
  • Constructor Details

  • Method Details

    • 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")