Unable to create extension with nested type.
I am trying to write an extension for the following XML.
<call xmlns='voiceaxis:state' id='1'><extension pbx_id='40277'/></call>
The outer <call> object works fine as an extension, but if I add a nested xml/java type for extension, (using an XmlJavaAdapter) the adapter never gets called.
I suspect that there may be an error when dealing with tags like <element/> rather than <element></element>
Comments (7)
-
Account Deactivated -
repo owner This is more of a general JAXB question. Have you tried adding a namespace declaration for each
@XmlElement
and each@XmlAttribute
? It's not sufficient to only put in the@XmlRootElement
.Alternatively, create a package-info.java. This is what I'd prefer.
-
Account Deactivated Yes, but not a package-info.java .. will try that as well.
On another note, is it not possible for the API to simply return the "original" events as a String ?
If I don't want to use extensions I need to type cast the payload of an event/item to an XML Node and then use low level API calls to get to its attributes. It would be nice if there was a way to get it back as a string.
-
Account Deactivated Thanks ! Adding package-info.java resolved it !!
-
repo owner Great! Getting the XML as String back is not quite that easy, I see no way actually. It's all built upon JAXB, so you really have to use Marshaller for a String representation.
If you don't use your extension, JAXB unmarshalls unknown XML as
org.dom.Element
, where you could use low-level API, but I guess you won't need it. -
repo owner - changed status to resolved
-
repo owner - changed status to closed
- Log in to comment
Some further info :- My type adapter does get called, but the String value to unmarshal is empty.
While this may make sense, the issue is that I cannot get the attributes of the <extension> tag.
The outer <call> tag is similarly empty, but it is of the form <call></call>, and for this element, JAXB does marshall the xml to java correctly.