GithubHelp home page GithubHelp logo

ricksladkey / generateds Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 6.0 620 KB

Generate Python data structures and XML parser from Xschema (Python 3 port)

License: Other

Python 99.94% Shell 0.03% C++ 0.02% C 0.01%

generateds's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

generateds's Issues

Order of children matters

One should have control over the order of children. Currently they are ordered in exportChildren by their Generateds class.
This is important, for example, for math prefix notation where / 1 2 is not the same as / 2 1.

generating some sql create tables with xsd

Hi, hope you can help me here.

I have some .xsd files where im trying to convert them to sql.

Do you know if it will be possible to do so leveraging the generateDS package?

Thank you,
Eliano

generateDS issue when using gends_generate_django.py

I would like to use the python script gends_generate_django.py from the generateDS toolbox to generate Django models from an initial XSD file.

According to the documentation (point 16.1) I would like to go through the following three steps:

  1. Generate bindings -- Run generateDS.py.
  2. ExtractsimpleType definitions from schema -- Run gends_extract_simple_types.py.
  3. Generate models.py and forms.py -- Run gends_generate_django.py.

Steps 1+2 could be completed successfully. In step 3 the following error message appears:

Traceback (most recent call last):
File
"SOME_PATH/generateds_code_2_40_12/gends_generate_django.py", line 208,
in
main()
File "SOME_PATH/generateds_code_2_40_12/gends_generate_django.py", line 202,
in main
generate_model(options, module_name)
File "SOME_PATH/generateds_code_2_40_12/gends_generate_django.py", line 96, in generate_model
supermod = importlib.import_module(module_name)
File "C:\ProgramData\Miniforge3\envs\gends_ws\lib\importlib_init_.py",
line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 961, in _find_and_load_unlocked
File "", line 219, in
_call_with_frames_removed
File "", line 1014, in _gcd_import
File "", line 991,
in _find_and_load
File "", line 973, in
_find_and_load_unlocked

ModuleNotFoundError: No module named 'SOME_PATH/generateds_definedsimpletypes'

Where generateds_definedsimpletypes.py is the output from running gends_extract_simple_types.py.

I have tried running the script both in the Conda environment and underself-installed Python. Moreover, I have used generateDS version 2.40.12. and Python 3.9.13.

What is my mistake when executing the script?

Many thanks for your replies!

Enumerations aren't properly working

When creating an element whose attribute is an enumeration in XSD, the element factory receives a string instead of an enumeration. It makes it necessary to explicit the enumeration value in order to properly export an .XML file.

For example, for the following generated enumeration:

class ProtectionActuation(Enum):
    PIOC='PIOC'
    PTOC='PTOC'
    RBRF='RBRF'
    PTUC='PTUC'

and the instanciation of an hypothetical element that has that enumeration attribute:
event= PSREvents.factory(name = ProtectionActuation.PIOC)

the exported XML file is mapped as:

        <PSREvents>
            <name>ProtectionActuation.PIOC</name>
        </PSREvents>

instead of:

        <PSREvents>
            <name>PIOC</name>
        </PSREvents>

(Although it could be easily fixed by expliciting its value:
event= PSREvents.factory(name = ProtectionActuation.PIOC.value)
)

Generated method validate_ISONormalisedDateTime is not working properly.

So, the code generated looks like this:

    def validate_ISONormalisedDateTime(self, value):
        result = True
        # Validate type ISONormalisedDateTime, a restriction on xs:dateTime.
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
            if not isinstance(value, datetime_.datetime):
                lineno = self.gds_get_node_lineno_()
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (datetime_.datetime)' % {"value": value, "lineno": lineno, })
                return False
            if not self.gds_validate_simple_patterns(
                    self.validate_ISONormalisedDateTime_patterns_, value):
                self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_ISONormalisedDateTime_patterns_, ))
                result = False
        return result

The value here is an datetime object type. Not a String, so the second if block is not working as expected.

gds_validate_simple_patterns(self.validate_ISONormalisedDateTime_patterns_, value)

Should validate the date pattern to a string not a datetime value.

I've fixed the generated code adding the sval of the Element to the validation and calling the regular expression validation with it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.