How can I supply a schema with a plugin.

I have developed an xml schema that I would like to supply with a plugin.
I need to register an external resource under resources.
There needs to be an URI and a path to the schema. The schema should be supplied with the plugin somehow.

How can I do this?

12 comments
Comment actions Permalink

Thank you for a prompt reply.
I still have some problems though.

1. Where should I put this code?
I put it in the constructor of my plugin application component class so it loads everytime the plugin starts.

2. I can't get it to work, here is the line of code:
ExternalResourceManager.getInstance().addStdResource("http://www.bindows.net","BindowsADFSchema.xsd", getClass());

I want to supply the xmlschema with the plugin so I just dropped the xsd in the same package folder as the rest of my classes.

I put it here:
BindowsPlugin
src
net.bindows.BindowsLauncher
All my files here...

When I go Settings->Resouces it is empty.

0
Comment actions Permalink

1. Where should I put this code?
I put it in the constructor of my plugin application
component class so it loads everytime the plugin
starts.


Yes, that's fine.

2. I can't get it to work, here is the line of code:
ExternalResourceManager.getInstance().addStdResource("
http://www.bindows.net","BindowsADFSchema.xsd",
getClass());

I want to supply the xmlschema with the plugin so I
just dropped the xsd in the same package folder as
the rest of my classes.

I put it here:
BindowsPlugin
src
net.bindows.BindowsLauncher
All my files here...
Settings->Resouces it is empty.


The schema must be contained somewhere in your classpath. So move it into your src folder and write "/BindowsADFSchema.xsd" (with a leading slash).

Oh yes, and you won't see anything in Settings -> Resources. Only the resources configured by the user are shown there. You have to open an XML file using your schema to check if it is registered correctly.

0
Comment actions Permalink

1. Where should I put this code?
I put it in the constructor of my plugin

application
component class so it loads everytime the plugin
starts.

Yes, that's fine.


Even better is to put it into the initComponent method.

0
Comment actions Permalink

Ok, nice but.

When I prepare my jar file the xsd file isnt included. How can I setup so it automatically includes it when I prepare the jar.

I tried to manually copy the xsd into the jar file (in the root dir) but that didnt work.

If I could get this to work it would be fantastic! :)

0
Comment actions Permalink

Most probably you should add ?*.xsd to 'Resource patterns' in compiler settings.

0
Comment actions Permalink

That did the trick for getting the xsd included.
Still can't get it to work though. Does the schema need to look a certain way or something?

I can get it to work if I set it up manually in the settings->resources so it should work...

In the xml file i type something like this to get the codecompletion:

]]>

Unfortunately the xmlns tag turns red and code completion does not work.

Any Ideas?

0
Comment actions Permalink

It works in the sandbox!
But not when I copy the plugin to my real IntelliJ plugins dir.

0
Comment actions Permalink

I'm quite sure that's a path problem. Check that the schema file is at the correct location relative to your application component class.

0
Comment actions Permalink

Not happening... :(
I put the schema in every folder and it still didnt work.
I also tried referencing the schema online: http://www.bindows.net/Schema/2.5/BindowsADFSchema.xsd
Not working either...

Any chance I can send you some files that you can take a look at?

Where is the sandbox directory btw?

0
Comment actions Permalink

Any chance I can send you some files that you can
take a look at?


Yes, send me the source file of your application component class and the complete jar which you are installing in the end.

Where is the sandbox directory btw?

If you didn't change it then it should be in ${user.home}/.IntelliJIdea60/sandbox

0
Comment actions Permalink

Thank God! I got it working. This was the problem:

BindowsADFSchema should have been BindowsAdfSchema

Still worked in sandbox but not in the real Intellij.

Thanks alot for your help!

0

Please sign in to leave a comment.