|
Re: Incompatible XML after DocumentRoot fix [message #416583 is a reply to message #416581] |
Wed, 06 February 2008 19:40 |
David Steinberg Messages: 489 Registered: July 2009 |
Senior Member |
|
|
Hi Ben,
So it sounds like you've fixed the extension parser registration to use
a resource with extended metadata enabled. That's good, since it's
suppressing the DocumentRoot properly and, hopefully, now producing a
serialization that conforms to your schema.
You can designate a default namespace in the XML simply by adding an
xmlns="http://some.namspace.com/" attribute to the root element. As long
as your use of namespaces in the document is consistent, EMF should be
able to load it.
The namespace mappings for the document are recorded in the
DocumentRoot's xMLNSPrefixMap feature. So, if you build up the document
programmatically and want to save it using a particular default
namespace, you can make the following registration on your DocumentRoot
instance before saving:
documentRoot.getXMLNSPrefixMap().put("", SomePackage.eNS_URI);
Note, though, that this isn't recommended, since it makes the null
namespace inaccessible. If you need access to it for local element
declarations, it won't be available.
What's your reason for not wanting to use a prefix to identify your
package namespace?
Cheers,
Dave
ben dixon wrote:
> At some point in editing my plugin, I accidentally introduced a
> DocumentRoot element into the serialized XML. I fixed this by
> correcting the type attribute for the parser in the
> org.eclipse.emf.ecore.extension_parser extension point. This removed
> the DocumentRoot as expected but what I didn't notice at the time is
> that the XML appears to have changed as well. Some attributes on
> elements that previously had no namespace appended to the front, now
> require the namespace. As a result, xml from the previous version of
> the plugin requires more changes than simply removing the
> DocumentRoot element. I'd like to adjust the namespace so that none
> of the attributes require having it appended (in effect designate a
> default namespace). I've tried editing the xml in various ways to
> accomodate this but EMF refuses to load the edited file. What
> determines how the namespaces are setup in the serialized XML?
|
|
|
Powered by
FUDForum. Page generated in 0.03737 seconds