I made the first step towards the solution of my problem. I can now map (the collection of) recursive elements with the following approach:
<mapping class="pack.Folder" extends="pack.Element" name="Folder">
<value field="Name" name="Name"/>
<collection field="Subfolder" usage="optional">
<structure map-as="pack.Folder"/>
</collection>
<value field="Description" name="Description"/>
</mapping>But one problem remains: How can I change the name of the element for the subfolders?
What I can map now is:
<Folder>
<Name>/home</Name>
<Folder>
<Name>/home/michi</Name>
<Folder>
<Name>/home/michi/docs</Name>
<Description>Michis Dokumente</Description>
</Folder>
<Description>Michis Home Verzeichnis</Description>
</Folder>
<Description>Home Verzeichnis</Description>
</Folder>But, what I want to map is the following:
<Folder>
<Name>/home</Name>
<subfolder>
<Name>/home/michi</Name>
<subfolder>
<Name>/home/michi/docs</Name>
<Description>Michis Dokumente</Description>
</subfolder>
<Description>Michis Home Verzeichnis</Description>
</subfolder>
<Description>Home Verzeichnis</Description>
</Folder>The difference is, that I want to be able to rename the "inside" Folder element (for instance to "subfolder"). I tried a few ways to accomplish this task but without success. Maybe someone can help me with this.
thanks Michael
Dennis Sosnoski wrote:
There shouldn't be any problem with this providing you use a <mapping> definition for the recursive structure. What you *can't* do is define it with a <structure> that just references back to itself (with "label" and "using"). If that's unclear reply back to the list with a sample of your current binding and we should be able to point you in the right direction.
- Dennis
Michael Kurz wrote:
Hi,
I use JIBX for a quite complex set of xml files defined by a schema-like structure. I ran into a problem (StackOverflow) when I tried to bind a recursive element with the following definition (I know it is not "real" xml schema):
<xsd:complexType name="Folder"> <xsd:element name="Name" type="xsd:String"/> <xsd:element name="subfolder" type="Folder" maxOccurs="unbounded"/> <xsd:element name="Description" type="xsd:String"/> </xsd:complexType>
I tried a few different ways to bind it without success.
My Question: Is there a way to bind recursive structures like this one? What I am currently planning to do is writing my own (de)serializer, what should not be too hard a job. But any "easier" solution would be welcomed.
thanks Michael
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
