Package org.eclipse.lemminx.utils

## Class DOMUtils

- java.lang.Object
- - org.eclipse.lemminx.utils.DOMUtils

    public class DOMUtils
    extends Object

DOM Utilities.

### Method Summary

All Methods Static Methods Concrete Methods
`static boolean` `containsTextOnly​(DOMElement element)` Returns true if element contains only DOMText and false otherwise.
`static InputSource` `createInputSource​(DOMDocument document)`
`static DOMElement` `findFirstChildElementByTagName​(DOMElement element, String tagName)`
`static boolean` `isCatalog​(DOMDocument document)` Returns true if the XML document is a XML Catalog and false otherwise.
`static boolean` `isDOMElement​(DOMNode node, String tagName)`
`static boolean` `isDTD​(String uri)` Returns true if the given URI is a DTD and false otherwise.
`static boolean` `isNonEmptyRange​(DOMRange range, boolean adjust)` Returns false if the range is zero-length, and true otherwise.
`static boolean` `isRelaxNG​(DOMDocument document)` Returns true if the XML document is a RelaxNG grammar and false otherwise.
`static boolean` `isRelaxNGUri​(String uri)` Returns true if the given URI is a RelaxNG grammar and false otherwise.
`static boolean` `isRelaxNGUriCompactSyntax​(String uri)` Returns true if the given URI is a RelaxNG grammar compact syntax and false otherwise.
`static boolean` `isRelaxNGUriXMLSyntax​(String uri)` Returns true if the given URI is a RelaxNG grammar XML syntax and false otherwise.
`static boolean` `isRelaxNGXMLSyntax​(DOMDocument document)` Returns true if the XML document is a RelaxNG grammar XML syntax and false otherwise.
`static boolean` `isXSD​(String uri)` Returns true if the given URI is a XML Schema and false otherwise.
`static boolean` `isXSD​(DOMDocument document)` Returns true if the XML document is a XML Schema and false otherwise.
`static boolean` `isXSL​(String uri)` Returns true if the given URI is a XSL and false otherwise.
`static boolean` `isXSL​(DOMDocument document)` Returns true if the XML document is a XSL and false otherwise.
`static DOMDocument` `loadDocument​(String documentURI, URIResolverExtensionManager resolverExtensionManager)` Returns the DOM document from the given XML Schema uri.
`static SAXParserFactory` `newSAXParserFactory()` Returns an instance of SAX parser factory by disabling external entities declarations.

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

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

### Method Detail

#### isXSD

    public static boolean isXSD​(DOMDocument document)

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

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

#### isXSD

    public static boolean isXSD​(String uri)

Returns true if the given URI is a XML Schema and false otherwise.

Parameters:
  `uri` - the URI to check
Returns:
  true if the given URI is a XML Schema and false otherwise.

#### isRelaxNG

    public static boolean isRelaxNG​(DOMDocument document)

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

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

#### isRelaxNGXMLSyntax

    public static boolean isRelaxNGXMLSyntax​(DOMDocument document)

Returns true if the XML document is a RelaxNG grammar XML syntax and false otherwise.

Returns:
  true if the XML document is a RelaxNG grammar XML syntax and false otherwise.

#### isRelaxNGUriXMLSyntax

    public static boolean isRelaxNGUriXMLSyntax​(String uri)

Returns true if the given URI is a RelaxNG grammar XML syntax and false otherwise.

Parameters:
  `uri` - the URI to check
Returns:
  true if the given URI is a RelaxNG grammar XML syntax and false otherwise.

#### isRelaxNGUri

    public static boolean isRelaxNGUri​(String uri)

Returns true if the given URI is a RelaxNG grammar and false otherwise.

Parameters:
  `uri` - the URI to check
Returns:
  true if the given URI is a RelaxNG grammar and false otherwise.

#### isRelaxNGUriCompactSyntax

    public static boolean isRelaxNGUriCompactSyntax​(String uri)

Returns true if the given URI is a RelaxNG grammar compact syntax and false otherwise.

Parameters:
  `uri` - the URI to check
Returns:
  true if the given URI is a RelaxNG grammar compact syntax and false otherwise.

#### isCatalog

    public static boolean isCatalog​(DOMDocument document)

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

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

#### isDTD

    public static boolean isDTD​(String uri)

Returns true if the given URI is a DTD and false otherwise.

Parameters:
  `uri` - the URI to check
Returns:
  true if the given URI is a DTD and false otherwise.

#### isXSL

    public static boolean isXSL​(DOMDocument document)

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

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

#### isXSL

    public static boolean isXSL​(String uri)

Returns true if the given URI is a XSL and false otherwise.

Parameters:
  `uri` - the URI to check
Returns:
  true if the given URI is a XSL and false otherwise.

#### containsTextOnly

    public static boolean containsTextOnly​(DOMElement element)

Returns true if element contains only DOMText and false otherwise.

Returns:
  true if element contains only DOMText and false otherwise.

#### loadDocument

    public static DOMDocument loadDocument​(String documentURI,
                                           URIResolverExtensionManager resolverExtensionManager)

Returns the DOM document from the given XML Schema uri.

Parameters:
  `documentURI` - the schema URI
  `resolverExtensionManager` -
Returns:
  the DOM document from the given XML Schema uri.

#### newSAXParserFactory

    public static SAXParserFactory newSAXParserFactory()
                                                throws SAXNotRecognizedException,
                                                       SAXNotSupportedException,
                                                       ParserConfigurationException

Returns an instance of SAX parser factory by disabling external entities declarations.

Returns:
  an instance of SAX parser factory by disabling external entities declarations.
Throws:
  `SAXNotRecognizedException`
  `SAXNotSupportedException`
  `ParserConfigurationException`

#### findFirstChildElementByTagName

    public static DOMElement findFirstChildElementByTagName​(DOMElement element,
                                                            String tagName)

#### isDOMElement

    public static boolean isDOMElement​(DOMNode node,
                                       String tagName)

#### createInputSource

    public static InputSource createInputSource​(DOMDocument document)

#### isNonEmptyRange

    public static boolean isNonEmptyRange​(DOMRange range,
                                          boolean adjust)

Returns false if the range is zero-length, and true otherwise.

Parameters:
  `range` - the range to check
  `adjust` - true if the leading and trailing quotes should be removed before checking if it's zero-length, false otherwise
Returns:
  false if the range is zero-length, and true otherwise