Menu

#5 Help with tag that can appear anywhere

2.0
closed
nobody
None
2021-10-12
2020-09-15
No

Hello,
I'm using the classes created with generateds only to write XML files and not read them. In particular, there is a type of tag which can be put inside any other tag, and I was wondering how to use the class. Usually when I have to add a tag inside another I just use the method "set_subtag" or "add_subtag", but in this case there is nothing. I attached the XML schema if it helps, the tag I'm referring to is called "userData".

1 Attachments

Discussion

  • Dave Kuhlman

    Dave Kuhlman - 2020-09-15

    Claudio,

    Good to hear from you.

    I generated a module from the OpenDRIVE XML schema with the
    following command:

    ./generateDS.py -o opendrivelib.py OpenDRIVE_1.5M.xsd
    

    Looking in the generated file (opendrivelib.py) and searching for class
    t_userData ... It has an instance variable (member) named
    anytypeobjs_. It is the result of the xs:any element inside
    xs:complexClass named t_userData. It's a list, and you can, I
    believe, add anything to it that you want. See methods in that
    class named: get_anytypeobjs_, set_anytypeobjs_,
    insert_anytypeobjs_, and add_anytypeobjs_. However, since
    generateDS.py doesn't know what these objects are, it's support
    for them is weak.

    The xs:any inside of t_userData allows you to insert any other
    object inside this one. However, in your message you ask about an
    object that you want to insert inside of any other object. So, I
    guess I have still not answered your question.

    However, as a partial answer to that question you need to look in
    the OpenDRIVE XML schema. Look where t_userData is referenced.
    It's referred to in <xs:group name="g_additionalData">. And, that
    is referred to (included in ?) lots of other complex types, for
    example, in OpenDRIVE and t_header and t_header_GeoReference
    and many more. In each of the classes generated from those complex
    types, you will find methods get_userData, set_userData, and, if
    it's a list also add_userData and insert_userData. You can add
    a t_userData in any of those objects.

    So, does that answer your question? Or, am I still not
    understanding you correctly?

    Dave

     
  • Claudio Kerov Ghiglianovich

    Okay, it does and apparently, I don't know why, I was using a file that was incomplete. Now I recreated the python file and the userData arguments are there. Thanks for your answer, if I'm still having problem I'll write again!

     
  • Dave Kuhlman

    Dave Kuhlman - 2021-10-12
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB