Class ContentModelManager


  • public class ContentModelManager
    extends Object
    Content model manager used to load XML Schema, DTD.
    • Method Detail

      • findCMDocument

        public Collection<CMDocument> findCMDocument​(DOMElement element)
        Returns the owner document of the declared element which matches the given XML element and null otherwise.
        Parameters:
        element - the XML element
        Returns:
        the owner document of the declared element which matches the given XML element and null otherwise.
      • findCMDocument

        public Collection<CMDocument> findCMDocument​(DOMElement element,
                                                     String namespaceURI)
        Returns the owner document of the declared element which matches the given XML element and null otherwise.
        Parameters:
        element - the XML element
        Returns:
        the owner document of the declared element which matches the given XML element and null otherwise.
      • findCMDocument

        public Collection<CMDocument> findCMDocument​(DOMDocument xmlDocument,
                                                     String namespaceURI,
                                                     boolean withInternal)
        Returns the declared documents which match the given DOM document.
        Parameters:
        xmlDocument - the DOM document.
        namespaceURI - the namespace URI
        Returns:
        the declared documents which match the given DOM document.
      • dependsOnGrammar

        public boolean dependsOnGrammar​(DOMDocument document,
                                        String grammarURI)
        Returns true if the given document is linked to the given grammar URI (XML Schema, DTD) and false otherwise.
        Parameters:
        document - the DOM document
        grammarURI - the grammar URI
        Returns:
        true if the given document is linked to the given grammar URI (XML Schema, DTD) and false otherwise.
      • getReferencedGrammarInfos

        public Set<ReferencedGrammarInfo> getReferencedGrammarInfos​(DOMDocument document)
        Returns informations about all referenced grammar (XSD, DTD) from the given DOM document.

        In other words, it gives information about

        • which XSD, DTD files are bound to the DOM document.
        • which binding strategies are used (catalog, file association, xsi:schemaLocation, xsi:noNamespaceSchemaLocation, DOCTYPE).
        • the cache file path (for remote grammar with http://)
        Parameters:
        document - the DOM document.
        Returns:
        informations about all referenced grammar (XSD, DTD) from the given DOM document.
      • getModelProviderByURI

        public ContentModelProvider getModelProviderByURI​(String uri)
        Returns the model provider by the given uri and null otherwise.
        Parameters:
        uri - the grammar URI
        Returns:
        the model provider by the given uri and null otherwise.
      • expandSystemId

        public String expandSystemId​(String path)
        Expand system Id
        Parameters:
        path - path to be expanded
        Returns:
        the expanded system Id
      • getCatalogs

        public String[] getCatalogs()
        Get XML catalogs.
        Returns:
        list of catalogs
      • setCatalogs

        public boolean setCatalogs​(String[] catalogs)
        Set up XML catalogs.
        Parameters:
        catalogs - list of XML catalog files.
        Returns:
        true if catalogs changed and false otherwise
      • refreshCatalogs

        public void refreshCatalogs()
        Refresh the XML catalogs.
      • setFileAssociations

        public boolean setFileAssociations​(XMLFileAssociation[] fileAssociations)
        Set file associations.
        Parameters:
        fileAssociations -
        Returns:
        true if file associations changed and false otherwise
      • setRootURI

        public void setRootURI​(String rootUri)
      • setUseCache

        public void setUseCache​(boolean useCache)
      • isDownloadExternalResources

        public boolean isDownloadExternalResources()
        Returns true if the external resources can be downloaded and false otherwise.
        Returns:
        true if the external resources can be downloaded and false otherwise.
      • setDownloadExternalResources

        public void setDownloadExternalResources​(boolean downloadExternalResources)
        Set true if the external resources can be downloaded and false otherwise.
        Parameters:
        downloadExternalResources - the external resources
      • evictCacheFor

        public void evictCacheFor​(DOMDocument document)
                           throws IOException
        Remove the referenced grammar from the given document and clear the Xerces grammar cache which stores the XSD, DTD grammar.
        Parameters:
        document - the DOM document
        Throws:
        IOException - if the delete of grammar file cannot be done.
      • evictCache

        public void evictCache()
                        throws IOException
        Remove the cache directory (.lemminx/cache) if it exists and clear the Xerces grammar cache which stores the XSD, DTD grammars.
        Throws:
        IOException - if the delete of directory (.lemminx/cache) cannot be done.
      • unregisterModelProvider

        public void unregisterModelProvider​(ContentModelProvider modelProvider)
      • isResolveExternalEntities

        public boolean isResolveExternalEntities()
        Returns true if external entities must be resolved and false otherwise.
        Returns:
        true if external entities must be resolved and false otherwise.
      • setResolveExternalEntities

        public void setResolveExternalEntities​(boolean resolveExternalEntities)
        Set true if external entities must be resolved and false otherwise.
        Parameters:
        resolveExternalEntities - resolve external entities
      • forceDownloadExternalResource

        public void forceDownloadExternalResource​(String url)
        Force the given url to download.
        Parameters:
        url - the url to download.!