Package org.eclipse.lemminx.dom
Class DOMDocument
- java.lang.Object
-
- org.eclipse.lemminx.dom.DOMNode
-
- org.eclipse.lemminx.dom.DOMDocument
-
-
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 Constructor Description DOMDocument(TextDocument textDocument, URIResolverExtensionManager resolverExtensionManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DOMNodeadoptNode(Node source)DOMAttrcreateAttribute(String name)DOMAttrcreateAttributeNS(String namespaceURI, String qualifiedName)DOMCDATASectioncreateCDataSection(int start, int end)CDATASectioncreateCDATASection(String data)DOMCommentcreateComment(int start, int end)DOMCommentcreateComment(String data)DocumentFragmentcreateDocumentFragment()DOMDocumentTypecreateDocumentType(int start, int end)DOMElementcreateElement(int start, int end)DOMElementcreateElement(String tagName)DOMElementcreateElementNS(String namespaceURI, String qualifiedName)EntityReferencecreateEntityReference(String name)DOMProcessingInstructioncreateProcessingInstruction(int start, int end)DOMProcessingInstructioncreateProcessingInstruction(String target, String data)DOMTextcreateText(int start, int end)DOMTextcreateTextNode(String data)Collection<DOMNode>findDTDAttrList(String elementName)Returns the DTD Attribute list for the given element name and empty otherwise.org.eclipse.lsp4j.jsonrpc.CancelCheckergetCancelChecker()DOMDocumentTypegetDoctype()DOMElementgetDocumentElement()StringgetDocumentURI()DOMConfigurationgetDomConfig()DOMElementgetElementById(String elementId)org.eclipse.lsp4j.RangegetElementNameRangeAt(int textOffset)Returns the element name on the left of the given position and null otherwise.NodeListgetElementsByTagName(String tagname)NodeListgetElementsByTagNameNS(String namespaceURI, String localName)StringgetExternalGrammarFromNamespaceURI()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.DOMImplementationgetImplementation()StringgetInputEncoding()LineIndentInfogetLineIndentInfo(int lineNumber)StringgetNamespaceURI()StringgetNodeName()shortgetNodeType()NoNamespaceSchemaLocationgetNoNamespaceSchemaLocation()Returns the declared "xsi:noNamespaceSchemaLocation" and null otherwise.DOMDocumentgetOwnerDocument()Returns the owner document and null otherwise.DOMNodegetProlog()If document has<?xml ... ?>, return this prolog, null otherwiseURIResolverExtensionManagergetResolverExtensionManager()List<DOMNode>getRoots()StringgetSchemaInstancePrefix()Returns the (xsi) schema instance prefix and null otherwise.SchemaLocationgetSchemaLocation()Returns the declared "xsi:schemaLocation" and null otherwise.StringgetSchemaPrefix()Returns the XML Schema prefix (ex : 'xs' for xmlns:xs="http://www.w3.org/2001/XMLSchema")booleangetStrictErrorChecking()StringgetText()Returns the text content of the XML document.TextDocumentgetTextDocument()org.eclipse.lsp4j.RangegetTrimmedRange(int start, int end)org.eclipse.lsp4j.RangegetTrimmedRange(org.eclipse.lsp4j.Range range)StringgetXmlEncoding()List<XMLModel>getXMLModels()Returns the list of xml-model processing instruction declared in the document.booleangetXmlStandalone()StringgetXmlVersion()booleanhasDTD()Returns true if XML document has a DTD declaration and false otherwise.booleanhasExternalGrammar()Returns true if the document is bound to an external grammar (XML file associations, XLM catalog) and false otherwise.booleanhasGrammar()Returns true if the document is bound to a grammar and false otherwise.booleanhasNamespaces()Returns true if document defines namespaces (with xmlns) and false otherwise.booleanhasNoNamespaceSchemaLocation()Returns true if XML root element declares a "xsi:noNamespaceSchemaLocation" and false otherwise.booleanhasProlog()If document has<?xml ... ?>booleanhasSchemaInstancePrefix()Returns true if (xsi) schema instance prefix exists.booleanhasSchemaLocation()Returns true if XML root element declares a "xsi:schemaLocation" and false otherwise.booleanhasXMLModel()Returns true if XML document has a xml-model processing declaration and false otherwise.DOMNodeimportNode(Node importedNode, boolean deep)booleanisBeforeProlog(int offset)Returns true, if the given offset is before XML declaration (<?xml ...?>), false otherwise.booleanisDTD()Returns true if the XML document is a DTD and false otherwise.booleanisWithinInternalDTD(int offset)Returns true if 'offset' is within an internal DOCTYPE dtd.StringlineDelimiter(int lineNumber)StringlineText(int lineNumber)voidnormalizeDocument()intoffsetAt(org.eclipse.lsp4j.Position position)org.eclipse.lsp4j.PositionpositionAt(int offset)DOMNoderenameNode(Node n, String namespaceURI, String qualifiedName)voidresetGrammar()Reset the cached grammar flag.voidsetCancelChecker(org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)voidsetDocumentURI(String documentURI)voidsetStrictErrorChecking(boolean strictErrorChecking)voidsetXmlStandalone(boolean xmlStandalone)voidsetXmlVersion(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()
-
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:
getNamespaceURIin interfaceNode- Overrides:
getNamespaceURIin classDOMNode
-
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:
getNodeTypein interfaceNode
-
getNodeName
public String getNodeName()
- Specified by:
getNodeNamein interfaceNode
-
getDocumentElement
public DOMElement getDocumentElement()
- Specified by:
getDocumentElementin interfaceDocument
-
getDoctype
public DOMDocumentType getDoctype()
- Specified by:
getDoctypein interfaceDocument
-
getOwnerDocument
public DOMDocument getOwnerDocument()
Description copied from class:DOMNodeReturns the owner document and null otherwise.- Specified by:
getOwnerDocumentin interfaceDOMRange- Specified by:
getOwnerDocumentin interfaceNode- Overrides:
getOwnerDocumentin classDOMNode- Returns:
- the owner document and null otherwise.
-
getDocumentURI
public String getDocumentURI()
- Specified by:
getDocumentURIin interfaceDocument
-
setDocumentURI
public void setDocumentURI(String documentURI)
- Specified by:
setDocumentURIin interfaceDocument
-
adoptNode
public DOMNode adoptNode(Node source) throws DOMException
- Specified by:
adoptNodein interfaceDocument- Throws:
DOMException
-
createAttribute
public DOMAttr createAttribute(String name) throws DOMException
- Specified by:
createAttributein interfaceDocument- Throws:
DOMException
-
createAttributeNS
public DOMAttr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException
- Specified by:
createAttributeNSin interfaceDocument- Throws:
DOMException
-
createCDATASection
public CDATASection createCDATASection(String data) throws DOMException
- Specified by:
createCDATASectionin interfaceDocument- Throws:
DOMException
-
createComment
public DOMComment createComment(String data)
- Specified by:
createCommentin interfaceDocument
-
createDocumentFragment
public DocumentFragment createDocumentFragment()
- Specified by:
createDocumentFragmentin interfaceDocument
-
createElement
public DOMElement createElement(String tagName) throws DOMException
- Specified by:
createElementin interfaceDocument- Throws:
DOMException
-
createElementNS
public DOMElement createElementNS(String namespaceURI, String qualifiedName) throws DOMException
- Specified by:
createElementNSin interfaceDocument- Throws:
DOMException
-
createEntityReference
public EntityReference createEntityReference(String name) throws DOMException
- Specified by:
createEntityReferencein interfaceDocument- Throws:
DOMException
-
createProcessingInstruction
public DOMProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
- Specified by:
createProcessingInstructionin interfaceDocument- Throws:
DOMException
-
createTextNode
public DOMText createTextNode(String data)
- Specified by:
createTextNodein interfaceDocument
-
getDomConfig
public DOMConfiguration getDomConfig()
- Specified by:
getDomConfigin interfaceDocument
-
getElementById
public DOMElement getElementById(String elementId)
- Specified by:
getElementByIdin interfaceDocument
-
getElementsByTagName
public NodeList getElementsByTagName(String tagname)
- Specified by:
getElementsByTagNamein interfaceDocument
-
getElementsByTagNameNS
public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
- Specified by:
getElementsByTagNameNSin interfaceDocument
-
getImplementation
public DOMImplementation getImplementation()
- Specified by:
getImplementationin interfaceDocument
-
getInputEncoding
public String getInputEncoding()
- Specified by:
getInputEncodingin interfaceDocument
-
getStrictErrorChecking
public boolean getStrictErrorChecking()
- Specified by:
getStrictErrorCheckingin interfaceDocument
-
getXmlEncoding
public String getXmlEncoding()
- Specified by:
getXmlEncodingin interfaceDocument
-
getXmlStandalone
public boolean getXmlStandalone()
- Specified by:
getXmlStandalonein interfaceDocument
-
getXmlVersion
public String getXmlVersion()
- Specified by:
getXmlVersionin interfaceDocument
-
importNode
public DOMNode importNode(Node importedNode, boolean deep) throws DOMException
- Specified by:
importNodein interfaceDocument- Throws:
DOMException
-
normalizeDocument
public void normalizeDocument()
- Specified by:
normalizeDocumentin interfaceDocument
-
renameNode
public DOMNode renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException
- Specified by:
renameNodein interfaceDocument- Throws:
DOMException
-
setStrictErrorChecking
public void setStrictErrorChecking(boolean strictErrorChecking)
- Specified by:
setStrictErrorCheckingin interfaceDocument
-
setXmlStandalone
public void setXmlStandalone(boolean xmlStandalone) throws DOMException- Specified by:
setXmlStandalonein interfaceDocument- Throws:
DOMException
-
setXmlVersion
public void setXmlVersion(String xmlVersion) throws DOMException
- Specified by:
setXmlVersionin interfaceDocument- 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")
-
-