While generating XML files with SimpleXml, I got challengefull problem.
I want to make dynamic xml output in the following way.
<process>
<sequence> ... </sequence>
<flow> ... </flow>
<sequence> ... </sequence>
<flow> ... </flow>
</process>
The question is How can I defined in the Schema using SimpleXMl?
Now, it looks in this way
@Root
public class Process {
@ElementList(inline=true, required = false)
private List<Sequences> sequence;
@ElementList(inline=true, required = false)
private List<Flows> flow;
}
According this schema it always generates XML in following format:
<process>
<sequence> ... </sequence>
<sequence> ... </sequence>
<flow> ... </flow>
<flow> ... </flow>
</process>
What should I do?
Thank you.
This is how you need to use from the documentation:
http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#scatter
Good luck.
Scattering inline element entries
Elements that are scattered throughout an XML document can be collected by inline lists and inline maps. Simply provide an entry name for the XML element name the list or map is to collect and they will be extracted and placed in to the collection object. For example take the following XML element. It contains include and exclude XML elements which are in no specific order. Even though they are not in any order the deserialization process is able to gather the XML elements as thet are encountered.
In order to achieve this the following object can be used. This declares two inline collections which specify the name of the entry objects that they are collecting. If the entry attribute is not specified then the name of the object will be used instead.