Home » Modeling » EMF » [EMF] Loading XML file with no namespace information
[EMF] Loading XML file with no namespace information [message #1008060] |
Fri, 08 February 2013 11:46  |
Eclipse User |
|
|
|
Hey all,
I've got a metamodel and XML files instancing it. These files do not point back to the metamodel with xmlns or contain any namespace information.
I've attempted to load these files by adding the metamodel's package to the registrymap under the null URI, like this:
resourceSet.getPackageRegistry().put(null, ePackage);
EPackage.Registry.INSTANCE.put(null, ePackage)
But have had no luck so far, and get "FeatureNotFoundException : feature [rootObject] not found" exceptions thrown whenever I try to load the resource. Any advice would be greatly appreciated.
Cheers,
Philippe
|
|
| |
Re: [EMF] Loading XML file with no namespace information [message #1008182 is a reply to message #1008066] |
Mon, 11 February 2013 05:19   |
Eclipse User |
|
|
|
Hi Ed, thanks for your reply!
Regarding the global registries: Thanks for the advice. It was a bit of a last-ditch effort, but I probably shouldn't have bothered to begin with.
As for the rest of your reply, I think I wasn't very clear, so I'll try and elaborate. I already have the XSD schema, as well as the corresponding Ecore model and API. The files I'm trying to load are provided by the user, and cannot be modified to include the namespace information.
I've tried looking around the package metadata and factory class, as per your suggestion, but haven't found anything out of the ordinary. Is there anything in particular that I should be looking out for?
I also have encountered a related problem that I hope you might be able to help with. My schema is heavily hierarchized. For the sake of explanation, let's say it goes like this :
<A>
<B>
<C>
</C>
<B>
</A>
If I manually add the namespace information to a file that describes an instance of A, everything's fine; If I do the same thing to a file describing an instance of B or C, I get the same error I described in my first message, ie. FeatureNotFoundException : feature B/C not found. Do you have any ideas on what I could do to fix this?
[Updated on: Mon, 11 February 2013 05:22] by Moderator
|
|
|
Re: [EMF] Loading XML file with no namespace information [message #1008342 is a reply to message #1008182] |
Tue, 12 February 2013 00:10  |
Eclipse User |
|
|
|
Philippe,
Comments below.
On 11/02/2013 11:19 AM, Philippe Roland wrote:
> Hi Ed, thanks for your reply!
>
> Regarding the global registries: Thanks for the advice. It was a bit
> of a last-ditch effort, but I probably shouldn't have bothered to
> begin with.
>
> As for the rest of your reply, I think I wasn't very clear, so I'll
> try and elaborate. I already have the XSD schema, as well as the
> corresponding Ecore model and API.
Does that schema have a target namespace?
> The files I'm trying to load are provided by the user, and cannot be
> modified to include the namespace information.
So the XML isn't actually valid with respect to the schema. (A schema
that specifies a target namespace implies that the instance must specify
that namespace.)
> I've tried looking around the package metadata and factory class, as
> per your suggestion, but haven't found anything out of the ordinary.
You really tried what I suggested? "I'd suggest finding or creating a
simple schema without a target namespace and generate an Ecore model
from it."
> Is there anything in particular that I should be looking out for?
Yes, I mentioned the particulars in my previous answer.
>
> I also have encountered a related problem that I hope you might be
> able to help with. My schema is heavily hierarchized. For the sake of
> explanation, let's say it goes like this : <A>
> <B>
> <C>
> </C>
> <B>
> </A>
> If I manually add the namespace information to a file that describes
> an instance of A, everything's fine; If I do the same thing to a file
> describing an instance of B or C, I get the same error I described in
> my first message, ie. FeatureNotFoundException : feature A not found.
Keep in mind that if you specify xmlns="...." on the root element then
every element in the document will be implicitly from that namespace,
and that might not correspond to your schema either.
> Do you have any ideas on what I could do to fix this?
Yes, but you need to look at the particulars I suggested already. I.e.,
if you modified your schema to remove the target namespace, what EMF
generates from it should be able to read instances without xmlns
declarations; of course it won't read instances that do include the
namespace, but maybe you don't need that...
|
|
|
Goto Forum:
Current Time: Tue Jul 22 22:05:29 EDT 2025
Powered by FUDForum. Page generated in 0.04036 seconds
|