D
D
Dmitry Sapronov2017-03-02 11:20:02
Java
Dmitry Sapronov, 2017-03-02 11:20:02

Is it possible to bypass the error of excessive nesting with the xml structure using jaxb annotations?

Hello comrades!
It so happened that xml comes to the soap client with approximately the following piece

<...>
<linked_documents>
  <linked_documents_items>
    <linked_documents_item>
      <uid>232323</uid>
      <extension>pdf</extension>
      <size>16387013</size>
      <id>64623</id>
      <name>тест</name>
      <date/>
    </linked_documents_item>
    <linked_documents_item>
      <uid>3455131</uid>
      <extension>pdf</extension>
      <size>354617</size>
      <id>168413245345587</id>
      <name>Тестовое наименование файла в связанных документах</name>
      <date>1470000000</date>
    </linked_documents_item>
  </linked_documents_items>
</linked_documents>
<...>

and there is a POJO with a field
private List<LinkedDocument> linkedDocuments;
where the LinkedDocument contains the following fields:
private String id;
private UUID uid;
private String extension;
private int size;
private String name;
private Integer date;

Task: use Jaxb2Marshaller to unmarshal.
The problem is that the xml contains a redundant linked_documents_items tag and I don't know how to tell annotations to ignore this tag. I can't create wrappers in podjiks. Can you please tell me whether it is possible to solve this problem with annotations and how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2017-03-02
@zolt85

You can do it like this (even you need to, probably)

@XmlElementWrapper(name = "linked_documents_items")
@XmlElement(name = "linked_documents_item")
private List<LinkedDocument> linkedDocuments;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question