"Manually setup external resource" pain

Hi,

I have the editor showing an XML file that uses some industry specific schemas.
In fact, no less than 9 distinct namespaces are used, all of them highlighted "red" by IDEA.

It happens to be that I have XSD schemas for all these 9 namespaces.
In fact, a module library that I'm referencing (as a maven dependency) comes with those schemas packaged.

When I select the "manually setup external resource", IDEA could do at least some of the manual work for me.
Specifically, scan the project classpath, finding .xsd files that have a matching targetNamespace, and suggest to pick one of the matches.

I'd still have to invoke the QuickFix nine times, but at least:
1) I won't have to navigate into some jar every time
2) I won't have to check-doublecheck that I've picked the right (sub)schema matching the right namespace

I think that, when working with product/company/industry specific schemas, there's a fair chance that the XSD(s) are to be found somewhere in the project classpath.
Does it make sense to file a YouTrack ticket for such a feature?

5 comments
Comment actions Permalink

IntelliJ does scan all project files to resolve namespaces.
If IntelliJ finds multiple copies of XSD that claim to define the same namespace the automatic resource resolution will fail.
If this is your case try excluding these in the project structure. When I did that IJ started resolving these properly.
It only took me 5 years to figure this out!

-Rob

0
Comment actions Permalink

Hi Rob,

I'm pretty sure I've never seen the "automagical" namespace-schema resolution work for me.

I think that the "Add schema location" QuickFix does try to be smart, and suggest schemas (schema location paths, to be specific).
However, my schema is in a (library) jar, and jar url paths are certainly not allowed in a xsi:schemaLocation attribute.

I don't think I have multiple matching schemas. However, since they're all in a jar library anyway, I cannot exclude (some).

I guess I'll just have put in the effort, and configure all namespace-schema mappings.
Since I've had to do this a number of times now, I've created a YouTrack ticket:
http://youtrack.jetbrains.net/issue/IDEA-55278

Cheers,
Taras

0
Comment actions Permalink

That "auto magical" behavior  may work for supported technologies like
Spring.
IMHO we could do the same for any xml namespaces.
Could it resolve your problem, Taras?

0
Comment actions Permalink

Hi Dmitry,

A SchemaProvider with a specific index populated from .xsd resources?
I think it would work nicely. But perhaps too automagical in some cases, should there be an option to disable it?

Anyway, if such an index was present, you could also go for a more conservative solution: if only a single discovered schema matches the unresolved namespace, you could also offer a specific QuickFix like "Assign to schema 'foo' [libary bar]".

0
Comment actions Permalink

IMHO an intention allowing to map the autodetected namespace to another
resource would be enough.
BTW could you submit a request for this feature?

0

Please sign in to leave a comment.