ricksladkey / generateds Goto Github PK
View Code? Open in Web Editor NEWGenerate Python data structures and XML parser from Xschema (Python 3 port)
License: Other
Generate Python data structures and XML parser from Xschema (Python 3 port)
License: Other
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:
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_unlockedModuleNotFoundError: 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!
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.
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.
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
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)
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.