Menu

#16 Can't generateds from xccdf 1.2 xsd file

1.0
open
nobody
None
2021-08-18
2021-08-12
Drew Beebe
No

Hi Dave,

I'm trying to use gends to create django models from the xccdf xsd file provided by NIST (https://csrc.nist.gov/schema/xccdf/1.2/xccdf_1.2.xsd).
When I do, I'm receiving the error below. It appears to be that it's reading in a null list from the xsd somewhere but I'm not sure how to proceed.
Any thoughts are welcome!

Thanks,
Drew

./gends_run_gen_django.py -f -v ./xccdf.xsd
schema_name_stem: xccdf
bindings_file_name: xccdflib.py
removing: xccdflib.py
running ./generateDS.py -f -o xccdflib.py --member-specs=dict ./xccdf.xsd
running ./gends_extract_simple_types.py -f ./xccdf.xsd
running ./gends_generate_django.py -f xccdflib
error
Traceback (most recent call last):
File "./gends_generate_django.py", line 251, in <module>
main()
File "./gends_generate_django.py", line 245, in main
generate_model(options, module_name)
File "./gends_generate_django.py", line 126, in generate_model
class_back_refs = make_class_back_refs(supermod, class_name_set)
File "./gends_generate_django.py", line 196, in make_class_back_refs
data_type = member_spec.data_type[0]
IndexError: list index out of range
</module>
error
message
ANY
message ***

Related

Tickets: #16

Discussion

  • Dave Kuhlman

    Dave Kuhlman - 2021-08-16

    Drew,

    Thanks for the report.

    I've been able to reproduce the exception.

    I believe that the superclass used by the Django support can get out
    of sync with the latest version generated by gDS. I don't normally
    try to keep the file django_etl/gends_generate_django.py
    up-to-date. Anyway, that's the first thing I'll check.

    By the way, comparing the lines and line numbers in the traceback,
    it seems that you are using the files in ./django_etl/ and not
    the ones under ./django/. Please let me know if I'm wrong about
    that.

    More later when I know more.

    Dave

     
  • Dave Kuhlman

    Dave Kuhlman - 2021-08-17

    Drew,

    The exception had a different cause than I expected. Anyway, I fixed that error, I believe. And, I've also updated the boilerplate in django_etl/generatedssuper.py. Now I can generate models.py, admin.py, and forms.py.

    If you get a chance to take a look, please let me know if it now does what you expect it to do.

    The new version (v. 2.39.4) is at SourceForge and PyPI.

    Thanks for help.

    Dave

     
    • Drew Beebe

      Drew Beebe - 2021-08-18

      Dave,

      First, let me take a moment to thank you ... a TON.

      Thanks for this project, as well as thank you for helping me with this
      particular issue.

      I've downloaded the new code, created a work directory, copied the .xsd
      file into that work directory. Then I copied the .py files from the root
      dir into the working directory and then copied the .py files from the
      django_etl directory into the working directory as well.
      I ran "python ./generateDS.py --export=django -o xccdf.py ./xccdf.xsd"
      and it generated the xccdf.py file, the xccdflib.py file and the
      generateds_definedsimpletypes.py, as expected.
      I then ran "./gends_run_gen_django.py -v ./xccdf.xsd" and it generated
      the forms.py, admin.py and models.py files, just as expected. This
      is an absolutely
      excellent
      tool to help with this endeavour!
      If I've not run the commands in the proper way or order, please let me
      know. I'm going to review the files now but I believe that it works as
      expected now.

      1 thing I wanted to ask you about --- in order to get this going, I had
      

      to do something a bit unusual and create a file folder structure OFF the
      root dir ('/') that followed the included xml path (for instance, I needed
      to create /schema/cpe/2.3 and place both the cpe-language_2.3.xsd and the
      cpe-naming_2.3.xsd files in that directory in order for generateDS.py to
      recognize them.

      The code that processes includes (process_includes.py) basically
      

      contains the logic that if the include starts with '/', it will look in the
      OS absolutely path (i.e. '/schema/cpe/2.3'). This is the case with the
      xccdf xsd file. The cpe xsd files start with the '/'.

      Anyway, THANK YOU for helping with fixing this issue and thank you for
      maintaining this project.
      I appreciate.

      -Drew

      On Tue, Aug 17, 2021 at 6:29 PM Dave Kuhlman dkuhlman@users.sourceforge.net
      wrote:

      Drew,

      The exception had a different cause than I expected. Anyway, I fixed that
      error, I believe. And, I've also updated the boilerplate in
      django_etl/generatedssuper.py. Now I can generate models.py, admin.py,
      and forms.py.

      If you get a chance to take a look, please let me know if it now does what
      you expect it to do.

      The new version (v. 2.39.4) is at SourceForge and PyPI.

      Thanks for help.

      Dave

      Status: open
      Milestone: 1.0
      Created: Thu Aug 12, 2021 10:50 AM UTC by Drew Beebe
      Last Updated: Mon Aug 16, 2021 08:25 PM UTC
      Owner: nobody

      Hi Dave,

      I'm trying to use gends to create django models from the xccdf xsd file
      provided by NIST (https://csrc.nist.gov/schema/xccdf/1.2/xccdf_1.2.xsd).
      When I do, I'm receiving the error below. It appears to be that it's
      reading in a null list from the xsd somewhere but I'm not sure how to
      proceed.
      Any thoughts are welcome!

      Thanks,
      Drew

      ./gends_run_gen_django.py -f -v ./xccdf.xsd
      schema_name_stem: xccdf
      bindings_file_name: xccdflib.py
      removing: xccdflib.py

      • running ./generateDS.py -f -o xccdflib.py --member-specs=dict
        ./xccdf.xsd * running ./gends_extract_simple_types.py -f ./xccdf.xsd

      • running ./gends_generate_django.py -f xccdflib * error

      • Traceback (most recent call last): File "./gends_generate_django.py",
        line 251, in <module> main() File "./gends_generate_django.py", line 245,
        in main generate_model(options, module_name) File
        "./gends_generate_django.py", line 126, in generate_model class_back_refs =
        make_class_back_refs(supermod, class_name_set) File
        "./gends_generate_django.py", line 196, in make_class_back_refs data_type =
        member_spec.data_type[0] IndexError: list index out of range </module>*
        error
        message

      * ANY * message ***

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/generateds/tickets/16/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Tickets: #16

  • Dave Kuhlman

    Dave Kuhlman - 2021-08-17

    Opps. I forgot to copy my temporary changes to the repo.
    That was dumb of me to do it this way.
    Now the changes are there.: v. 2.39.5
    And, they've been uploaded.

    Dave

     
  • Drew Beebe

    Drew Beebe - 2021-08-18

    Dave,

    First, let me take a moment to thank you ... a TON.

    Thanks for this project, as well as thank you for helping me with this particular issue.

    I've downloaded the new code, created a work directory, copied the .xsd file into that work directory. Then I copied the .py files from the root dir into the working directory and then copied the .py files from the django_etl directory into the working directory as well.
    I ran "python ./generateDS.py --export=django -o xccdf.py ./xccdf.xsd" and it generated the xccdf.py file, the xccdflib.py file and the generateds_definedsimpletypes.py, as expected.
    I then ran "./gends_run_gen_django.py -v ./xccdf.xsd" and it generated the forms.py, admin.py and models.py files, just as expected. This is an absolutely excellent tool to help with this endeavour!
    If I've not run the commands in the proper way or order, please let me know. I'm going to review the files now but I believe that it works as expected now.

    1 thing I wanted to ask you about --- in order to get this going, I had to do something a bit unusual and create a file folder structure OFF the root dir ('/') that followed the included xml path  (for instance, I needed to create /schema/cpe/2.3 and place both the  cpe-language_2.3.xsd and the cpe-naming_2.3.xsd files in that directory in order for generateDS.py to recognize them.
    
    The code that processes includes (process_includes.py) basically contains the logic that if the include starts with '/', it will look in the OS absolutely path (i.e. '/schema/cpe/2.3'). This is the case with the xccdf xsd file. The cpe xsd files start with the '/'.
    

    Anyway, THANK YOU for helping with fixing this issue and thank you for maintaining this project.
    I appreciate.

    -Drew

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.