Issue
I have some customized (different file extensions than the conventional .xml files) XML files on my Eclipse RCP application and I need Eclipse to display error markers like it does for .xml files when the format is incorrect (for example if there's no end tag for the beginning tag or if the angle brackets are missing). I can easily set this up manually in Preferences -> Validation -> XML Validator -> Settings -> Add new File Extension Rule for my custom file extensions and after setting up this preference the error markers correctly display for my custom XML files when the format is incorrect but I would like this behavior to apply even though the preferences are not set for different file extensions (something we could setup using .ini file).
When I set the File Extension Rule for my custom file extensions then Eclipse stores this following preference in org.eclipse.wst.validation.prefs node -
vals/org.eclipse.wst.xml.core.xml/groups=0107include07111contentType128org.eclipse.core.runtime.xmlT111contentType134org.eclipse.wst.xml.core.xmlsourceT111contentType134org.eclipse.wst.xml.core.xslsourceT111contentType134org.eclipse.jst.jsp.core.tldsourceT07fileext03xmlF07fileext06varselF07fileext06vardefF0107exclude05113projectNature134org.eclipse.jst.j2ee.ejb.EJBNature113projectNature130org.eclipse.jst.j2ee.EARNature04file08.projectT0104file110.classpathT0104file110.settings/T02
And I tried adding the same entry to my product's .ini file and expected the settings to be read upon the product start and the validation behavior to be applied on my Eclipse RCP product to my custom file extension XML files without explicitly setting the preferences manually.
I looked upon the internet for solutions but got nowhere close, what am I doing wrong here? Are the entries I added to my .ini file correct? How can I enable validation for my custom file extension XML files (XML files with different file extensions)?
Solution
A better solution would be to add filename extensions to the relevant Content Type, via an "extension" element in your own plugin.xml
file. Then almost every feature meant for XML files will, or should, apply to your own--validators, editors, task tag scanning, etc. The Platform defines one content type for XML files, and the WTP XML plug-ins define another specifically for files that could be considered ill-formed or syntactically broken, the ones that would be unreadable by most production XML parsers. They are org.eclipse.core.runtime.xml
and org.eclipse.wst.xml.core.xmlsource
, respectively. The Validation framework will then automatically consider your files as candidates for the XML Validator.
Answered By - nitind
Answer Checked By - David Marino (JavaFixing Volunteer)