problem with parser?

47 views
Skip to first unread message

Jim

unread,
Oct 8, 2009, 1:46:30 AM10/8/09
to Tefkat
Hi,

I'm just picking up tefkat for the first time in a very, very long
time, and I found a problem that looks like its in the parser
somewhere. I can comment all the rules/patterns etc in my
transformation and still get the same result, so I think its something
basic about the parser, or resource loading.

Error is as follows...

java.io.IOException: Could not load 'platform:/resource/qut.ifc/model/
express2ecore.qvt': org.xml.sax.SAXParseException: Content is not
allowed in prolog.
at tefkat.plugin.TefkatPlugin.getResource(Unknown Source)
at tefkat.plugin.TefkatPlugin.execute(Unknown Source)
at tefkat.plugin.TefkatPlugin.run(Unknown Source)
at tefkat.plugin.TefkatBuilder.doBuild(Unknown Source)
at tefkat.plugin.TefkatBuilder.build(Unknown Source)
at org.eclipse.core.internal.events.BuildManager$2.run
(BuildManager.java:627)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:170)
at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:201)
at org.eclipse.core.internal.events.BuildManager$1.run
(BuildManager.java:253)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:256)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop
(BuildManager.java:309)
at org.eclipse.core.internal.events.BuildManager.build
(BuildManager.java:341)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild
(AutoBuildJob.java:140)
at org.eclipse.core.internal.events.AutoBuildJob.run
(AutoBuildJob.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
$1DiagnosticWrappedException: org.xml.sax.SAXParseException: Content
is not allowed in prolog.
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException
(ResourceSetImpl.java:315)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper
(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource
(ResourceSetImpl.java:397)
... 17 more
Caused by: org.xml.sax.SAXParseException: Content is not allowed in
prolog.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException
(Unknown Source)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError
(Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError
(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl
$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next
(Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:
181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad
(XMLResourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load
(ResourceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load
(ResourceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad
(ResourceSetImpl.java:255)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper
(ResourceSetImpl.java:270)
... 18 more

Any suggestions?

Jim.

Ed Willink

unread,
Oct 8, 2009, 5:45:49 AM10/8/09
to tef...@googlegroups.com
Hi Jim

That looks like what happens when you pass a non-XML file to an XML loader.

Regards

Ed Willink

Jim Steel

unread,
Oct 8, 2009, 9:46:42 AM10/8/09
to tef...@googlegroups.com
Yeah, its kinda strange. We're implementing extension_parser with the
file extension, but for some reason its trying to use the xml parser
anyway.

Jim

unread,
Nov 19, 2009, 10:40:20 PM11/19/09
to Tefkat

Hi Ed (on the offchance you're still reading this forum)

I am working on a different project (based on using Tefkat to write
some transformations), implementing another metamodel (actually 2)
with a non-XML file serialization. I have copied the approach to
resource implementations used by Tefkat, and (unsurprisingly) I am
seeing the above problem again. What Tefkat (and what I'm doing with
these other metamodels/resourceImpls) does is:
1) create TefkatResourceFactoryImpl to implement
org.eclipse.emf.ecore.resource.Resource.Factory and its createResource
(uri) method
2) create TefkatResourceImpl as a subclass of XMIResourceImpl and
overriding doLoad(inputstream, map), and doSave(outputstream, map)
3) implement the extension_parser extension point to associate
the .qvt extension with the TefkatResourceFactoryImpl

So this used to work, but doesn't any more. I assume this is because
we are taking the shortcut of subclassing XMIResourceImpl, and
something has changed in the way that resource sets load resource
impls. I tried subclassing ResourceImpl instead of XMIResourceImpl
(which just by the names would seem to be a good idea), but it didn't
change that error at all.

Cheers,

Jim.

Ed Willink

unread,
Nov 20, 2009, 1:36:56 AM11/20/09
to tef...@googlegroups.com
Hi Jim

> Hi Ed (on the offchance you're still reading this forum)
>
With low traffic, this newsgroup is often good value.

> I am working on a different project (based on using Tefkat to write
> some transformations), implementing another metamodel (actually 2)
> with a non-XML file serialization. I have copied the approach to
> resource implementations used by Tefkat, and (unsurprisingly) I am
> seeing the above problem again. What Tefkat (and what I'm doing with
> these other metamodels/resourceImpls) does is:
> 1) create TefkatResourceFactoryImpl to implement
> org.eclipse.emf.ecore.resource.Resource.Factory and its createResource
> (uri) method
> 2) create TefkatResourceImpl as a subclass of XMIResourceImpl and
> overriding doLoad(inputstream, map), and doSave(outputstream, map)
> 3) implement the extension_parser extension point to associate
> the .qvt extension with the TefkatResourceFactoryImpl
>
> So this used to work, but doesn't any more. I assume this is because
> we are taking the shortcut of subclassing XMIResourceImpl, and
> something has changed in the way that resource sets load resource
> impls. I tried subclassing ResourceImpl instead of XMIResourceImpl
> (which just by the names would seem to be a good idea), but it didn't
> change that error at all.
>
Yes things are much improved. There are now content types.

The appropriate ResourceFactory to load a file used to be chosen

a) URI-based
b) extension based

Now a content-based choice, if available, precedes the extension-based.

At the platform level these are registered and can be browsed in
Windows->Proferences->General->Content Types.

Content types are defined by the
org.eclipse.core.contenttype.contentTypes extension point with an
associated content describer. See org.eclipse.ocl/plugin.xml for a
non-trivial example.

EMF enables these via the Model.Content Type Identifier genmodel field,
leading to an eCONTENT_TYPE in the Package class. NB genmodel doesn't
update plugin.xml at all, so you might want to experiment creating from
your Ecore model from scratch to see what a virgin plugin.xml copuld
look like.

The ResourceSet load on finding an XML file offers the file to each of
the registered content describers. These can prioritise their
appropriateness allowing the best to be chosen. It is the the backstop
XML handler that crashes on non-XML. Prior to the backstop EMF supports
a namespace-based dispatch of XML to a model-specific loader. You can
therefore have 100 different meta-models all sharing the .xml extension.

The code is not trivial to understand with the platform performing a
useful job in not quite the way that suits EMF, so EMF fights it a bit.

If you put in your own describer, you can probably do interesting things.

There might be a tutorial now. 'content type' and 'content describer'
are the important keywords.

Regards

Ed Willink

michael lawley

unread,
Nov 23, 2009, 1:17:34 AM11/23/09
to tef...@googlegroups.com
Thanks Ed, this is really useful info.

It's somewhat frustrating the way that upgrades to EMF cause bit-rot
based on non-regeneration of files like plugin.xml, etc But it's
handy to be reminded that this is an issue that needs to be monitored
as new versions come out.

Cheers,

michael

2009/11/20 Ed Willink <e...@willink.me.uk>:
Reply all
Reply to author
Forward
0 new messages