eclipse-pluginoclpapyrus

get "SAXSparseEception: Content is not allowed in prolog" when parsing an OCL file in my Eclipse plugin


I am working on my own eclipse plugin, which includes parsing CompleteOCL file. I worked it out when I run the plugin by click on the "Luanch an Eclipse application" in overview tab of plugin.xml. But since I wanted to deploy the plugin elsewhere, I wrote a simple product file and click the run button on the product file, It occurs an error says "SAXSparseEception: 'Constraints.ocl'; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog".

I checked the encoding of my complete ocl file, and it is UTF-8.(I think this is OK.)

https://www.eclipse.org/forums/index.php/t/1075241/ This page gave me a clue, in the answers, "The Web editor does not use Equinox. That's why you have to register the respective EPackage in the standalone setup manually. In Equinox, this happens by means of the extension point "org.eclipse.emf.ecore.generated_package"." I don't know if this would help in my occasion, because I developed the plugin in Eclipse Papyrus, and it contains Equinox in the first place. What should I do? Thanks in advance.


Solution

  • It looks as if the *.ocl file is being read as XML and diagnosed as not-XML. This is usually because the appropriate Xtext setup has not been invoked to register the *.ocl to 'XML' parser. Try invoking

    org.eclipse.ocl.xtext.completeocl.CompleteOCLStandaloneSetup.doSetup()