> From: Domenico Mangieri

>Sent: Tuesday, August 13, 2013 1:37 AM
> 

Domenico -

Good to hear from you.  More notes are below.

> 
> I’m using generateDS to create code from xsd, thanks for building
> this.. it’s a really useful tool.

Great.  Glad to hear that.

> 
> I’ve created some unit tests for my app, and I corrected 3
> behaviours in the generated code.
> 
> Just emailing you in case you want to change them
> 
> - Printing xml in various parse functions.  This is only useful for
>   debugging, would be good to have an option to generate or hide
>   that code.  i.e.
> 
>     sys.stdout.write('#from riskdb_xsd import *\n\n')
>     sys.stdout.write('import riskdb_xsd as model_\n\n')
>     sys.stdout.write('rootObj = model_.rootTag(\n')
>     rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
>     sys.stdout.write(')\n')

If I understand you correctly, there already is an option for this.
See the --silence command line option.

But, if you are looking for a way to use the same generated code but
to turn it off sometimes and turn it on other times, then you're
right; gDS does not do that. ... No, wait.  I just now made a fix so
that the parse functions will take an additional, optional argument
that turns export on or off.

My suggestion to solve *that* problem would be to write your own
module in which you import the generated code and insert copies of
which ever parse function you need from the generated code (parse(),
parseEtree(), parseString(), ...).  You will need to modify that
parse function a bit.  When you this, you will be able to regenerate
the main code without over-writing your custom code.

You may also want to look at the parse functions and the subclasses
of the data representation classes that you get when you use the -s
command line option.

> 
> - When parsing iso date with Z at the end, the code set the
>   timezone to GMT, the standard in this case should be UTC
> 
> - When writing a float the code uses
> 
>       def gds_format_float(self, input_data, input_name=''):
>           return '%f' % input_data
> 
>   This operation rounds up the decimals up to 6 digits.. in
>   scientific calculations this can be a problem.
> 
>   In my case I’ve changed to code to capture 15 digits
> 
>       def gds_format_float(self, input_data, input_name=''):
>           return '%.15f' % input_data

Seems like a good idea to me.  More precission must be better then
less.

However, consider this modification of your fix, which strips off
trailing zeroes:

    def gds_format_float(self, input_data, input_name=''):
        return ('%.15f' % input_data).rstrip('0')

Does that still get you what you need?  For many use cases, the
precision implied by all those zeroes is bogus.

I've pushed a version with your changes and a few more to Bitbucket:
https://bitbucket.org/dkuhlman/generateds
in case you want to try it.  But, I plan to do some more testing
before actually releasing a new version.

Here are notes from the README on these changes:

    Version 2.11a (08/14/2013)
    - Added ability to use XML catalog to find included/imported
      schemas.  Thanks to George David for implementing this
      enhancement.
    - Added ability to pick up the target namespace and its prefix, then
      use them in calling the export functions from the parse functions.
      Thanks to George David for suggesting this.
    - Several fixes to formatting date and floats during export.  Thanks
      to Domenico Mangleri for catching and fixing these.
    - Added generation of an extra, optional "silence" argument to the
      parse functions so that export can be turned on or off at runtime.
      Domenico is the motivator on this one, too.
    - The information about minOccurs and maxOccurs in the generateDS
      document (generateDS.txt) was misleading or wrong.  Edited it.
      Thanks to Rinat Yangurazov for catching this.

Thanks again for help.  And, please let me know whether that float
fix seems acceptible to you.

- Dave


--


Dave Kuhlman
http://www.rexx.com/~dkuhlman

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to