Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generated editor for XSD generated Ecore model
Generated editor for XSD generated Ecore model [message #423836] Tue, 07 October 2008 18:44 Go to next message
Cameron Bateman is currently offline Cameron BatemanFriend
Messages: 480
Registered: July 2009
Senior Member
When I generated the editor code for an Ecore model that I generated from
an XSD model, I had to override createModel to get it to work.

Specifically, I had to change the generated XMIResource that gets used to
an XMLResource derivation by changing the resource factory on the resource
set and setting the extended metadata option. Second, I had to hack the
uri converter list on the resource set to allow the sax parser to find the
dtd for the original model (I used a DTD->XSD conversion to generate the
ecore model).

Are these known limitations of using generated editors with XSD-based
models or are there one more settings or better ways to accomplish
document loading? I'm particularly concerned by having to cast
resourceSet.getURIConverter() to ExtensibleURIConverterImpl so that I can
insert my converter first on the list.


Thanks,

Cameron
Re: Generated editor for XSD generated Ecore model [message #423838 is a reply to message #423836] Tue, 07 October 2008 19:04 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30896
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000308010106090405090007
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Cameron,

Comments below.


Cameron Bateman wrote:
> When I generated the editor code for an Ecore model that I generated
> from an XSD model, I had to override createModel to get it to work.
Really?
>
> Specifically, I had to change the generated XMIResource that gets used
> to an XMLResource derivation by changing the resource factory on the
> resource set and setting the extended metadata option.
The presence of extended meta data at the time the GenModel is created
normally results in the GenPackage's Resource Type being set to XML and
all the right things are normally generated from there.. There's
support for content types in EMF 2.4, so that would let you have many
different models that all use *.xml extension...
> Second, I had to hack the uri converter list on the resource set to
> allow the sax parser to find the dtd for the original model (I used a
> DTD->XSD conversion to generate the ecore model).
Hack?! :-P You had to make sure that this XMLHandler method was able
to resolve the system ID?

public InputSource resolveEntity(String publicId, String systemId)
throws SAXException
{
try
{
Map<Object, Object> options = new HashMap<Object, Object>();
options.put("publicId", publicId);
options.put("systemId", systemId);
options.put("baseLocation", resourceURI == null ? null :
resourceURI.toString());
URI uri = URI.createURI(systemId);
if (resolve && uri.isRelative() && uri.hasRelativePath())
{
uri = helper.resolve(uri, resourceURI);
}
InputStream inputStream =
getURIConverter().createInputStream(uri, options);
InputSource result = new InputSource(inputStream);
result.setPublicId(publicId);
result.setSystemId(systemId);
return result;
}
catch (IOException exception)
{
throw new SAXException(exception);
}
}

Note that the uri_mapping extension point can be used to globally
register redirections. I'm not sure that would help.

>
> Are these known limitations of using generated editors with XSD-based
> models or are there one more settings or better ways to accomplish
> document loading?
No, these are all surprising things. But one thing to keep in mind is
that GenModel/GenPackage/Gen* settings are preserved once you've created
them the first time, so significant changes that would have affected the
initializations have no effect later on. (Of course plugin.xml and
MANIFEST.MF don't regenerate unless you delete them.)
> I'm particularly concerned by having to cast
> resourceSet.getURIConverter() to ExtensibleURIConverterImpl so that I
> can insert my converter first on the list.
That seems odd. Why would you need to do that. Which list?
URIConverter has a getURIHandlers list. And the URIConverter.getURIMap
is configurable for redirects...

>
>
> Thanks,
>
> Cameron
>

--------------000308010106090405090007
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Cameron,<br>
<br>
Comments below.<br>
<br>
<br>
Cameron Bateman wrote:
<blockquote
cite="mid:610f1b5c4f734ae4039df4b0137469fe$1@www.eclipse.org"
type="cite">When I generated the editor code for an Ecore model that I
generated from an XSD model, I had to override createModel to get it to
work.
<br>
</blockquote>
Really?<br>
<blockquote
cite="mid:610f1b5c4f734ae4039df4b0137469fe$1@www.eclipse.org"
type="cite"><br>
Specifically, I had to change the generated XMIResource that gets used
to an XMLResource derivation by changing the resource factory on the
resource set and setting the extended metadata option. <br>
</blockquote>
The presence of extended meta data at the time the GenModel is created
normally results in the GenPackage's Resource Type being set to XML and
all the right things are normally generated from there..
Previous Topic:Creating my on derived feature based on a "mixed" feature
Next Topic:Feature not found loading serialized resource
Goto Forum:
  


Current Time: Sat Feb 22 06:23:35 GMT 2020

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

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

Back to the top