>From: Per Wetterberg <dtv00...@hotmail.com> >To: generateds-users@lists.sourceforge.net >Sent: Saturday, August 13, 2011 12:09 AM >Subject: [Generateds-users] How do I parse an xml document containing >xsd:choice >
> I cant figure out how to parse an xml schema containing xsd:choice. > > How do I parse the following xml document using generateDS? I want > to keep the order of the elements (motorcycle, boat, motorcycle, > helicopter). Per - Good to hear from you. Thanks for the comment. If you want to preserve the order of children across different types of children, then generateDS.py does not do that. generateDS.py is intended to make it more convenient to access child elements by type, rather than to access them in the order in which they occur in the original instance document. If the original order of child elements within a parent element is important to you, then you may want to consider using ElementTree or Lxml instead of generateDS.py. Lxml has something called objectify (see http://lxml.de/objectify.html), which is intended to be a more Pythonic interface to the XML DOM tree. Maybe you could consider the objectify API as being somewhere in between the straight ElementTree/Lxml API and the API generated by generateDS.py. With that in mind, I believe that any suggestions I give with respect to generateDS.py are likely to be somewhat of a kludge. However, ... If you mark the vehicles class as mixed, then the generated code will preserve the order of child elements. I suppose that we could adopt some of that behavior generated for mixed elements for all elements, even those that are not mixed, so that the order of child elements is preserved during export. I'll have to look into that. OK. I did a little study and made a trial fix. Attached is a patch that you can apply to version 2.6a. It causes generateDS.py to generate code that effectively treats all elements as mixed. It seems to have the behavior that you want (although the export of closing tags for empty elements is a bit different). I *told* you it would be a kludge. - Dave
generateds.patch
Description: Binary data
------------------------------------------------------------------------------ uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users