Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XML serialization try to handle xmlns:... attributes
XML serialization try to handle xmlns:... attributes [message #667419] Thu, 28 April 2011 15:22 Go to next message
Renat Zubairov is currently offline Renat ZubairovFriend
Messages: 30
Registered: July 2009
Member
I have an issue inside the XMLHandler class. I have an XML which I should be de-seralized into ECORE model that I will show in the editor. I have a ecore + genmodel, generated model code and initialized package before loading.

I'm parsing a sequence of SAX attributes, first SAX call gives a root object and it's attributes that is handled by XMLHandler. DocumentRoot from the model as well as it's first child is created successfully (namespace, registry lookup all ok) however then happening strange things.

My root element obviously has a namespace declaration, something like

<env:root xmlns:env="blahblahblah">


However then I've got a following exception:

org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'env' not found. (platform:/resource/TestData/cuscar.edi, -1, -1)


This is happening because XMLHandler is trying to handle xmlns:env attribute inside XMLHandler.setAttribValue which is obviously ending in exception because my model does not have such 'env' attribute.

I'm using following code to create my SAX Attribute object:

attrs.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE + ":" + envelopePrefix, XMLConstants.XMLNS_ATTRIBUTE + ":" + envelopePrefix, "CDATA", handlerFactory.getNamespace());


My question is why attributes explicitly defined in XMLConstants.XMLNS_ATTRIBUTE_NS_URI is handled. BTW SAXHandler is namespace aware.

Thnx.

Renat
Re: XML serialization try to handle xmlns:... attributes [message #667532 is a reply to message #667419] Fri, 29 April 2011 11:21 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Renat Zubairov wrote:
> I have an issue inside the XMLHandler class. I have an XML which I
> should be de-seralized into ECORE model that I will show in the
> editor. I have a ecore + genmodel, generated model code and
> initialized package before loading.
>
> I'm parsing a sequence of SAX attributes, first SAX call gives a root
> object and it's attributes that is handled by XMLHandler. DocumentRoot
> from the model as well as it's first child is created successfully
> (namespace, registry lookup all ok) however then happening strange
> things.
>
> My root element obviously has a namespace declaration, something like
>
>
> <env:root xmlns:env="blahblahblah">
>
>
> However then I've got a following exception:
>
>
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'env' not
> found. (platform:/resource/TestData/cuscar.edi, -1, -1)
>
>
> This is happening because XMLHandler is trying to handle xmlns:env
> attribute inside XMLHandler.setAttribValue which is obviously ending
> in exception because my model does not have such 'env' attribute.
>
> I'm using following code to create my SAX Attribute object:
>
>
> attrs.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
> XMLConstants.XMLNS_ATTRIBUTE + ":" + envelopePrefix,
> XMLConstants.XMLNS_ATTRIBUTE + ":" + envelopePrefix, "CDATA",
> handlerFactory.getNamespace());
You're making your own DOM?
>
>
> My question is why attributes explicitly defined in
> XMLConstants.XMLNS_ATTRIBUTE_NS_URI is handled. BTW SAXHandler is
> namespace aware.
Is the DOM itself you're making namespace aware?
>
> Thnx.
>
> Renat
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EMF] Inter-model Inheritance viewer in EMF editor
Next Topic:Per-package customisation of generated class names?
Goto Forum:
  


Current Time: Fri Apr 26 21:55:37 GMT 2024

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

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

Back to the top