Great! I will try the new version soon. 

Thanks for the prompt response

Dom

-----Original Message-----
From: Dave Kuhlman [mailto:dkuhl...@rexx.com] 
Sent: 13 August 2013 23:44
To: Domenico Mangieri
Cc: generateds-users@lists.sourceforge.net
Subject: Re: generateDS

> 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


The information in this e-mail is confidential and may be legally privileged. 
It is intended solely for the addressee(s). Access by any other person to this 
e-mail is not authorized. If you are not the intended recipient, please delete 
this e-mail. Any disclosure of this e-mail or of the parties to it and any 
copying or distribution of it is prohibited (and may be unlawful). The 
information expressed herein may be changed at any time without notice or 
obligation to update. We do not represent that this message is virus-free, 
complete or accurate and it should not be relied upon as such. Electronic 
communications may be monitored for operational and business purposes to the 
extent permitted by applicable law. This email does not constitute legal or tax 
advice, and the information contained in this communication should not be 
regarded as such.
------------------------------------------------------------------------------
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