Find XML Schema in Project

Answered

I noticed that IntelliJ automatically detect XML Schema files in the project and makes the target namespace known in other places. This mechanism would be really helpful for my plugin. Is there a way to tap into it and ask it if it knows a specific namespace and where the schema file is?

0
6 comments

Hi,

I'm not sure I understand what feature you mean. Could you please show an example on a screenshot or link to the IDEA web help feature description?

0

The function described here 

https://www.jetbrains.com/help/idea/referencing-xml-schemas-and-dtds.html

Even works without schemaLocation when an xsd file for the namespace is somewhere in the project.

0

Please see com.intellij.xml.XmlSchemaProvider.

0

Sadly findSchema always returns null. And getAvailableProviders returns an empty list. 

I will give more information what I am talking about. One of the imports in this picture is green. The others are red. That's because this one namespace is defined by the model.xsd file next to this file. But it doesn't matter where it is in the project. It sounds like findSchema should give me the model.xsd file when asked for its namespace. What else can I try?

0

Any idea where I can look for this? The XmlSchemaProvider interface sounds right but it seems the only implementation has to do with JavaFX and has nothing to do with this feature.

0

I found it. It's the function findNSFilesByURI in XmlUtil.

0

Please sign in to leave a comment.