|
Re: Strategy for Dynamic Model Generation from XSD [message #420860 is a reply to message #420859] |
Mon, 14 July 2008 21:01 |
Ed Merks Messages: 33139 Registered: July 2009 |
Senior Member |
|
|
Mike,
Comments below.
Mike Gering wrote:
> I am failing to get dynamically generated models to work for me. I
> don't know if this is due to an EMF limitation or just my lack of
> understanding of how to do it.
>
> Here's the scenario. I have generated a model and editor from schema A
> with nsURI = "foo". I want to handle a case where I get a document
> that includes extensions to A defined by schema B (nsURI = "bar"). I
> don't know in advance that the document uses Schema B, but the schema
> is available and specified by the schemaLocation attribute in the
> document. As best I can tell, XSDEcoreBuilder will always create a
> dynamic package for schema A. Even if I put A in the local package
> registry, the builder overwrites it.
>
> I saw in a post in 2005 about a "trick" of unloading the resource for
> A and causing it to be reloaded from the global registry, but I don't
> see where I can insert that trick. And I don't know if there is a
> better way.
Yes, this is a bit tricky, because the XSDEcoreBuilder wants to load and
map each schema and then it establishes a mapping from the schema
objects to the corresponding Ecore objects. So even if a static package
exists already, the mapping to use it isn't populated. I'd need to
think carefully about the easiest approach to implement something like
this. I could imagine that once the EPackage for A is created by the
build, that you'd unload it and hence turn all the objects into
proxies. Then the EPackage for B would need to resolve those references
and if the registry is set up such that the proxy resolve find the
static package, that would work nicely.
If you wanted to create a stand alone test case to simulate the
situation, I'd be happy to help produce something that works well. We
could put the result in the wiki as a recipe to help others in the future...
>
> Any advice?
I'll have some time to look at this tomorrow...
>
> Thanks,
> Mike Gering
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03542 seconds