Eugene, So, are we good with your fix? My test seems to show that it is working, but I'm unsure about your comment below. I'll leave it alone unless I get another nudge from you. If you still find an error, please let me know.
And, thanks for your help with this. About running the unit tests, do: $ cd tests $ python test.py You will need to use Python 2.7 and not Python 3 to run the unit tests. The unit tests will run under Python 3, but the tests fail. That's because of (1) differences in the generated comments at the top of generated files; (2) some ordering differences, possibly because of dicts; etc. all of which do not matter when you actually run the generated code, I believe. I should add a README to the tests/ subdirectory. ... Done (but not yet at the Bitbucket repository. You asked about adding a new test for this mixed content capability. Let me look into that, since I've done it before and since we now have an example. ... Done. It's basically a matter of adding a new function to test/test.py and then creating the needed data files (e.g. a .xsd and possibly .xml files). Oh, and the name of the test function must start with "test_", I believe. And, thanks for giving me a nudge to add this test. See this for more on the Python unit test framework: https://docs.python.org/2/library/unittest.html With respect to creating instances of the "mixed content" classes programmatically -- When a class is generated from an xs:complexType that is marked mixed="true", the generated class must save some additional information. This is done so that the class can remember the order of nested elements and character content items. You can look at the `buildChildren` method in a class generated from an xs:complexType that is marked mixed="true" in order to see how this is done. I looked at one just now. It's pretty twisted. Did I really write the code that generates that? I don't know whether to be proud that it's so complicated or ashamed that it's so complicated. Keeping the order and placement of items in mixed content is a bit hairy. Thanks again for help. Dave On Wed, Nov 15, 2017 at 03:23:48AM +0300, Eugene Petkevich wrote: > Hi Dave, > > Sorry for the non-obvious formatting of the last e-mail I've sent to you; > perhaps you have not noticed the second part of the e-mail. > > You've merged the pull request of mine that hopefully solves the mixed > content output issues. I wondered whether generateDS uses any kind of > automated testing. I noticed the 'tests' directory in the repository but > it is not straightforward to me how to run all the tests at once. > > Best regards, > Eugene > > On 15.11.2017 02:42, Dave Kuhlman wrote: > > Eugene, > > > > I apologize for being slow. I've been working on a few other > > things. > > > > Looks like you are creating the instances of these classes > > programmatically. So, I'm trying to do the same. Perhaps that will > > help me find out where the problem is. > > > > I'll report back soon, I hope. > > > > Dave > > > > On Thu, Nov 09, 2017 at 06:58:16PM +0300, Eugene Petkevich wrote: > > > Hi Dave, > > > > > > I apologize for the late answer. Yes, when using your attached module > > > with schema by that simple script: > > > > > > import tmp02sup as g > > > r = > > > g.rootType.factory(markup=[g.markupType.factory(embedded=['hello'], > > > nested=[g.nestedType.factory()], > > > > > > valueOf_='world')]) > > > with open('./test.xml', 'w') as f: > > > r.export(f, 0) > > > > > > And resulting XML is: > > > > > > <rootType> > > > <markup> > > > </markup> > > > </rootType> > > > > > > So no output was exported within the markup element. I guess your > > > example > > > XML was regarding reading -- yes, reading worked correctly without any > > > problems, only exporting back to XML was a problem. > > > > > > On 27.10.2017 23:06, Dave Kuhlman wrote: > > > > > > Eugene, > > > > > > For you information, I've accepted and merged your pull request that > > > fixes the export of mixed content elements. I apologize for being > > > so slow. > > > > > > Thanks much for this. > > > > > > The updated code is at Bitbucket > > > (https://bitbucket.org/dkuhlman/generateds) > > > and at the Python Package Index. > > > > > > Dave > > > > > > > > > I hope my patch solved the issue correctly. How do you usually test > > > the > > > library? I can try to make some tests (though I'm not experienced > > > much > > > within that area, so that could take more time). Also, I see some > > > code > > > which works on Python2 but not Python3, do you think it make sense to > > > make > > > the code run in both Python versions? > > > > > > Best regards, > > > Eugene > > > On 30.09.2017 02:06, Dave Kuhlman wrote: > > > > > > Eugene, > > > > > > With respect to: > > > (1) Export of content with mixed="True". > > > > > > I created a simple XML schema and XML instance document. I > > > generated a module from the schema with generateDS.py. When I run > > > the generated module against the XML instance document, I see the > > > following output: > > > > > > $ python tmp02sup.py test01.xml > > > <?xml version="1.0" ?> > > > <root> > > > <markup> > > > This markup has <embedded>content</embedded> withing it. > > > </markup> > > > <markup> > > > This markup has > > > <nested> > > > <nested2>Some nested text</nested2> > > > <nested3>1234</nested3> > > > </nested> > > > > > > withing it. > > > </markup> > > > </root> > > > > > > As you can see, the nested elements are exported. (We can argue > > > about the new lines and white space later.) > > > > > > So, there must be some case that my simple example is not covering. > > > Most likely I had the same narrow focus and omission when I've > > > worked on this in the past. > > > > > > Perhaps you can tell me how to modify my example schema so that your > > > issue is exposed. > > > > > > I've attached my schema and instance document and generated module. > > > I'll attach the generated module to a separate message so as not to > > > stuff bulk in too many mailboxes. > > > > > > By the way, I'm using the following versions (which you can tell by > > > looking at the top of the generated module): > > > > > > # Generated Fri Sep 29 15:40:19 2017 by generateDS.py version 2.28b. > > > # Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 > > > 20170118] > > > > > > I'll look into issues (2) and (3) on Monday. Hope your weekend > > > is/was a good one. > > > > > > Dave > > > > > > > > > On Wed, Sep 27, 2017 at 05:09:24AM +0300, Eugene Petkevich wrote: > > > > > > Dear generateDS team, > > > > > > I've tried to work on solve several issues regarding XML output by > > > generateDS and need some help. Here are the issues: > > > > > > (1) Export of content with mixed="True". > > > I noticed that elements with mixed="True" are not exported at all, both > > > their children and text value are missing in XML files. I've managed to > > > change the code that is working, but not sure whether I fully understand > > > everything related to mixed element implementation in generateDS. I've > > > made > > > a pull request for that change: > > > > > > https://bitbucket.org/dkuhlman/generateds/pull-requests/26/fix-for-exporting-elements-with-mixed-true/diff > > > > > > (2) Namespace prefixes are not preserved when using includes and > > > imports. > > > Here I noticed that all export functions for all elements are generated > > > with > > > the target namespace of the input schema. Even if it includes or > > > imports > > > another schemas with different target namespaces. Thus, in the > > > resulting > > > XML every element has the same namespace, even if they are supposed to > > > have > > > different namespaces. I've tried to check the code and see that > > > includes and > > > imports are preprocessed, and original namespaces are not preserved in > > > both > > > generateDS code and generated code. I've tried to implement the fix in > > > generateDS, but didn't manage yet. Maybe you have an advice on how to > > > approath the issue? > > > > > > (3) When exporting subtyped elemetns, 'xsi:type=...' attribute is not > > > exported. > > > What is missing in generated code is the only assignment: > > > self.extensionType_ = '<type>' > > > or calling extensionType='<type>' in constructor of the class. But > > > again > > > I'm not sure where in generateDS should I put that. > > > > > > Currently all three issues make it impossible to export a corrent XML > > > (that > > > is validated against the corresponding schema); while it reads XMLs > > > correctly, generating corresponding classes, and reading children > > > elements > > > and mixed text. > > > > > > A temporary solution to the issues was to use a combination of Mix-in > > > classes and edits in the generated code. > > > > > > Best regards, > > > Eugene > > > > > > > > > ------------------------------------------------------------------------------ > > > Check out the vibrant tech community on one of the world's most > > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > > > generateds-users mailing list > > > generateds-users@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/generateds-users > -- Dave Kuhlman http://www.davekuhlman.org ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users