I’m serializing a very simple graph into an XML using xStream, I have this output which is pretty close from what I want:
<grafo>
<nodo id="1">
<nodo id="2"/>
</nodo>
<nodo id="2">
<nodo id="3"/>
<nodo id="4"/>
</nodo>
<nodo id="3">
<nodo id="5"/>
</nodo>
<nodo id="4">
<nodo id="6"/>
</nodo>
</grafo>
But I need in the output that every node inside another node (an edge) to appear with the alias "child" and not with "nodo".
I do not believe you can do this with simple aliases. But you can do it with a custom serializer like below. The xstream doc has a good converter tutorial which includes details on how to register a custom converter.