Class ContentModelManager
- java.lang.Object
-
- org.eclipse.lemminx.extensions.contentmodel.model.ContentModelManager
-
public class ContentModelManager extends Object
Content model manager used to load XML Schema, DTD.
-
-
Constructor Summary
Constructors Constructor Description ContentModelManager(URIResolverExtensionManager resolverManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandependsOnGrammar(DOMDocument document, String grammarURI)Returns true if the given document is linked to the given grammar URI (XML Schema, DTD) and false otherwise.voidevictCache()Remove the cache directory (.lemminx/cache) if it exists and clear the Xerces grammar cache which stores the XSD, DTD grammars.voidevictCacheFor(DOMDocument document)Remove the referenced grammar from the given document and clear the Xerces grammar cache which stores the XSD, DTD grammar.StringexpandSystemId(String path)Expand system IdCollection<CMDocument>findCMDocument(DOMDocument xmlDocument, String namespaceURI)Collection<CMDocument>findCMDocument(DOMDocument xmlDocument, String namespaceURI, boolean withInternal)Returns the declared documents which match the given DOM document.Collection<CMDocument>findCMDocument(DOMElement element)Returns the owner document of the declared element which matches the given XML element and null otherwise.Collection<CMDocument>findCMDocument(DOMElement element, String namespaceURI)Returns the owner document of the declared element which matches the given XML element and null otherwise.voidforceDownloadExternalResource(String url)Force the givenurlto download.String[]getCatalogs()Get XML catalogs.LSPXMLGrammarPoolgetGrammarPool()ContentModelProvidergetModelProviderByURI(String uri)Returns the model provider by the given uri and null otherwise.Set<ReferencedGrammarInfo>getReferencedGrammarInfos(DOMDocument document)Returns informations about all referenced grammar (XSD, DTD) from the given DOM document.booleanisDownloadExternalResources()Returns true if the external resources can be downloaded and false otherwise.booleanisResolveExternalEntities()Returns true if external entities must be resolved and false otherwise.voidrefreshCatalogs()Refresh the XML catalogs.voidregisterModelProvider(ContentModelProvider modelProvider)booleansetCatalogs(String[] catalogs)Set up XML catalogs.voidsetDownloadExternalResources(boolean downloadExternalResources)Set true if the external resources can be downloaded and false otherwise.booleansetFileAssociations(XMLFileAssociation[] fileAssociations)Set file associations.voidsetResolveExternalEntities(boolean resolveExternalEntities)Set true if external entities must be resolved and false otherwise.voidsetRootURI(String rootUri)voidsetUseCache(boolean useCache)voidunregisterModelProvider(ContentModelProvider modelProvider)
-
-
-
Constructor Detail
-
ContentModelManager
public ContentModelManager(URIResolverExtensionManager resolverManager)
-
-
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)
-
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 documentgrammarURI- 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 IOExceptionRemove 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.
-
registerModelProvider
public void registerModelProvider(ContentModelProvider modelProvider)
-
unregisterModelProvider
public void unregisterModelProvider(ContentModelProvider modelProvider)
-
getGrammarPool
public LSPXMLGrammarPool getGrammarPool()
-
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 givenurlto download.- Parameters:
url- the url to download.!
-
-