XML serialization try to handle xmlns:... attributes [message #667419] |
Thu, 28 April 2011 15:22 |
Renat Zubairov 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 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.03223 seconds