Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » My validatorV2 extension disables XML source validation
My validatorV2 extension disables XML source validation [message #785407] Sun, 29 January 2012 00:19 Go to next message
John Ruud is currently offline John RuudFriend
Messages: 6
Registered: July 2009
Junior Member
I'd like to add XML editor source (as-you-type) validation for my own xml based content type ("xml2"). However, contributing the org.eclipse.wst.validation.validatorV2 extension as shown below seems to disable source validation for the original org.eclipse.core.runtime.xml content type (and it doesn't work for my xml2 type either).

Normal batch validation still works for both xml and xml2. Source validation clearly stopped working because no red squiggly lines are drawn for invalid <tag></tag2> elements (for example) when editing xml or xml2 files using the WST XML editor. I'm using Eclipse JEE/Indigo SR1:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.core.contenttype.contentTypes">
      <content-type
            base-type="org.eclipse.core.runtime.xml"
            file-extensions="xml2"
            id="validator-test.xml2"
            name="XML2"
            priority="normal">
      </content-type>
   </extension>
   <extension
         id="id1"
         name="name"
         point="org.eclipse.wst.validation.validatorV2">
      <validator
            build="true"
            class="org.eclipse.wst.xml.core.internal.validation.eclipse.Validator"
            manual="true"
            markerId="org.eclipse.wst.xml.core.validationMarker"
            sourceid="org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidatorForXML"
            version="3">
         <include>
            <rules>
               <contentType
                     exactMatch="true"
                     id="validator-test.xml2">
               </contentType>
            </rules>
         </include>
      </validator>
   </extension>


If I remove the source validator entry (sourceid="org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidatorForXML") from my plugin.xml then source validation starts working again for the normal xml content type (but obviously not for my own content type).

Has anybody been able to get source validation to work for their own XML based content type? DelegatingSourceValidatorForXML seems to stop working properly after it's been re-contributed. Source validation *mostly* works if I remove the validatorV2 extension and instead manually add my content type to: Preferences + Validation + XML validator + Settings, while there has been a couple of times when that stopped working as well (and I needed to remove and then add them back in).

John
Re: My validatorV2 extension disables XML source validation [message #786097 is a reply to message #785407] Mon, 30 January 2012 01:20 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2335
Registered: July 2009
Senior Member
On 1/28/2012 7:19 PM, John Ruud wrote:
> I'd like to add XML editor source (as-you-type) validation for my own
> xml based content type ("xml2"). However, contributing the
> org.eclipse.wst.validation.validatorV2 extension as shown below seems to
> disable source validation for the original org.eclipse.core.runtime.xml
> content type (and it doesn't work for my xml2 type either).
> Normal batch validation still works for both xml and xml2. Source
> validation clearly stopped working because no red squiggly lines are
> drawn for invalid <tag></tag2> elements (for example) when editing xml
> or xml2 files using the WST XML editor. I'm using Eclipse JEE/Indigo SR1:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.4"?>
> <plugin>
> <extension
> point="org.eclipse.core.contenttype.contentTypes">
> <content-type
> base-type="org.eclipse.core.runtime.xml"
> file-extensions="xml2"
> id="validator-test.xml2"
> name="XML2"
> priority="normal">
> </content-type>
> </extension>
> <extension
> id="id1"
> name="name"
> point="org.eclipse.wst.validation.validatorV2">
> <validator
> build="true"
> class="org.eclipse.wst.xml.core.internal.validation.eclipse.Validator"
> manual="true"
> markerId="org.eclipse.wst.xml.core.validationMarker"
> sourceid="org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidatorForXML"
>
> version="3">
> <include>
> <rules>
> <contentType
> exactMatch="true"
> id="validator-test.xml2">
> </contentType>
> </rules>
> </include>
> </validator>
> </extension>
>
> If I remove the source validator entry
> (sourceid="org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidatorForXML")
> from my plugin.xml then source validation starts working again for the
> normal xml content type (but obviously not for my own content type).
>
> Has anybody been able to get source validation to work for their own XML
> based content type? DelegatingSourceValidatorForXML seems to stop
> working properly after it's been re-contributed. Source validation
> *mostly* works if I remove the validatorV2 extension and instead
> manually add my content type to: Preferences + Validation + XML
> validator + Settings, while there has been a couple of times when that
> stopped working as well (and I needed to remove and then add them back in).

A few things to try:
1) Don't borrow the XML Problem marker type, use your own. The
Validation Framework will not be able to manage them properly if they
come from more than one validator.
2) Don't associate your batch validator with an unrelated source
validator. You're confusing the framework.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: My validatorV2 extension disables XML source validation [message #825308 is a reply to message #786097] Tue, 20 March 2012 17:56 Go to previous messageGo to next message
olivier pod is currently offline olivier podFriend
Messages: 3
Registered: March 2012
Junior Member
Hello,
I am interested in a solution to this problem as I have to do exactly the same thing.
Nitin, could you please explain a little bit more your two suggestions please ?

Thanks.

-Olivier-
Re: My validatorV2 extension disables XML source validation [message #826945 is a reply to message #785407] Thu, 22 March 2012 17:33 Go to previous messageGo to next message
John Ruud is currently offline John RuudFriend
Messages: 6
Registered: July 2009
Junior Member
I couldn't get it to work earlier (when using the extension points).

Do your validators work if you manually make the associations, as opposed to using the extensions?

John
Re: My validatorV2 extension disables XML source validation [message #827040 is a reply to message #826945] Thu, 22 March 2012 20:28 Go to previous messageGo to next message
olivier pod is currently offline olivier podFriend
Messages: 3
Registered: March 2012
Junior Member
Hi,
at first, I didn't try to manually associate the validators as I didn't initially considered to override any existing implementation (I just want the exactly same behaviour as the XML, but for my own content-type which only differs from the XML content-type by the file extension).

(By the way, I'm not sure of what you mean when you ask "Do your validators work if you manually make the associations ?").

So, I just tried to "duplicate" as many contributions needed for the XML content-type, but for my own specific "XML-like" content-type to get the same functionalities (problem marker, sourcevalidation and ValidatorV2 as far as I remember).

For now, all functionnalities work for XML and only the "as-you-type" validation doesn't work for my content-type.
Now, I'm trying to figure out why it doesn't work by debugging the WST validator framework by comparing the call stacks/code calling tree between an editor on an XML file and another one on my own content-type.

I think I'm not far of a solution by declaring a sourcevalidation contribution and a ValidatorV2 pointing on a Validator class which default internal validator ID is pointing on the Validator markerId value. I'll detail a little bit more this particular point tomorrow from work.
Regards and sorry for the long post.
Re: My validatorV2 extension disables XML source validation [message #827153 is a reply to message #827040] Fri, 23 March 2012 00:24 Go to previous messageGo to next message
John Ruud is currently offline John RuudFriend
Messages: 6
Registered: July 2009
Junior Member
I manually associated my content type(s) with the default XML validators by doing: Window + Preferences + Validation + 'XML Validator' + Settings, and then added my content types to the Include Group, because the sourcevalidation or validatorV2 extensions didn't seem to work with the default XML validators.

However, I'd be interested to hear if you manage to get the extensions to work. I'm thinking there might be some subtle differences between how the extensions work vs. how the manually added associations work, but my wild guess is that there is something about the xml validator implementation that causes the different behavior when the extensions are used.

John
Re: My validatorV2 extension disables XML source validation [message #829874 is a reply to message #827153] Mon, 26 March 2012 22:55 Go to previous messageGo to next message
olivier pod is currently offline olivier podFriend
Messages: 3
Registered: March 2012
Junior Member
It works !
In fact, one has to associate the sourcevalidation and the validatorV2 extensions with two different validator classes. I'm at home now, so I don't remember which classes I set, but if I have a few minutes at work, I'll post again to tell you.

-Olivier-
Re: My validatorV2 extension disables XML source validation [message #829949 is a reply to message #829874] Tue, 27 March 2012 01:45 Go to previous messageGo to next message
John Ruud is currently offline John RuudFriend
Messages: 6
Registered: July 2009
Junior Member
That's very cool - I would be very interesting in seeing what the extension points look like or which validator classes are working!

John
Re: My validatorV2 extension disables XML source validation [message #899695 is a reply to message #829874] Wed, 01 August 2012 21:55 Go to previous messageGo to next message
brandon shirley is currently offline brandon shirleyFriend
Messages: 1
Registered: August 2012
Junior Member
Is there any way you could post a sample of the code you used to get the xml validation to work. I've wasted a lot of time on it and have not been able to get all the pieces working.
Re: My validatorV2 extension disables XML source validation [message #905089 is a reply to message #785407] Wed, 29 August 2012 16:56 Go to previous message
Leonid Ripeynih is currently offline Leonid RipeynihFriend
Messages: 107
Registered: February 2012
Senior Member
I'm very interesting on getting source validation working with own xml-based format as well. I've tried the standart extension schema - and it's not working. Would appreciate a sample plugin.xml snipet very much!
Previous Topic:XML and Maven properties
Next Topic:Deployment assembly of projects that include bianry class folders
Goto Forum:
  


Current Time: Wed Nov 26 09:26:53 GMT 2014

Powered by FUDForum. Page generated in 0.03012 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software