Marc, Here is a fix for you to try. My test shows that it exports attributes and elements even when their current value is equal to the default value. I'm not sure that my test covers all possible cases (attributes and elements with different data types), but I tried.
The new command line option that you will need to use is "--always-export-default". I'll send the patched version of generateDS.py in a separate email. Please give it a try. If it works for you, I'll commit it and push it to the Bitbucket repository. And, thanks for suggesting this feature. Dave On Tue, Feb 20, 2018 at 11:47:05AM +0000, Marc Capavanni wrote: > Hi Dave, > > I can understand that reasoning. In my case I validate the XML before > giving it to another component which doesn't have access to the original > XSD, and thus doesn't know the default values. > > If it's not too much trouble that command line option would be ideal. > > In my use case I only have defaults set for elements (and don't foresee > this changing), so I don't have a preference. Whatever you think is best > for the codebase and is convenient for you :) > > Thanks, > Marc > > > On 19 February 2018 at 23:08, Dave Kuhlman <dkuhl...@davekuhlman.org> wrote: > > > Marc, > > > > The thinking is that if the current value and the default value are > > the same, we do not need to write our that attribute, since when > > read back in, the attribute will be given that value anyway. > > > > Apparently, for your use case, this thinking is not correct. > > > > If that's true, I can add a command line option so that attributes > > with values equal to the default value will be exported. But, you > > want to know that if we did this and you use that option, *all* > > attributes with the current value equals their default value will be > > exported. > > > > Is that what you need and want? > > > > Let me know. Adding that new command line option should be > > reasonably easy to do. > > > > Or, do you need this control on an element by element and attribute > > by attribute basis? That would be more messy. > > > > And, by the way, I'm happy to hear that generateDS.py has been > > useful. > > > > Dave > > > > On Fri, Feb 16, 2018 at 03:31:53PM +0000, Marc Capavanni via > > generateds-users wrote: > > > Hi there, > > > > > > Thanks for the great library, it's really useful. > > > > > > I use the library to create a Python API class to generate XMLs based off > > > XSDs. > > > > > > I have a XSD which has the following line. > > > > > > <xs:element default="0.95" name="volume" type="ct:volumeType"/> > > > > > > However when I generated my XML, this element is missing. > > > > > > When looking at the generated code I see this. > > > > > > if self.volume != 0.95: > > > showIndent(outfile, level, pretty_print) > > > outfile.write('<%volume>%s</%volume>%s' % (namespace_, > > > self.gds_format_double(self.volume, input_name='volume'), namespace_, > > eol_)) > > > > > > Is this possible? > > > > > > Thanks in advance, > > > Marc > > > > > ------------------------------------------------------------ > > ------------------ > > > 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 > > -- 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