kiishor / xml_code_generator

This application parses XML schema file and generates C source code for parsing xml file.
MIT License
4 stars 1 forks source link

Using complex type as type in more than one elements #27

Open AsfaMehmood opened 1 year ago

AsfaMehmood commented 1 year ago

Hi Kiishor,

I have just started using your xml_code_generator as well as miniML parser in my project and I received compilation error in the .c and .h file generated by xml_code_generator. When I assign same complex type to two elements, the tool generates same structures twice. Similarly, if I use 3 elements of same complextype, it generates 3 structures with same names for each of my elements.

To make it work: I had to remove extra definitions of same structure from both .c and .h files. But I do not want to edit it every time I generate files from tool. Is there a solution to it?

I am attaching the generated files as well as my .xsd and .xml files.

RootElement.c.txt RootElement.h.txt Sample.xml.txt Sample.xsd.txt

kiishor commented 1 year ago

Hi AsfaMehmood,

Thanks for reporting this bug, I will fix this bug soon.

Regards, Nandkishor

kiishor commented 1 year ago

Hi AsfaMehmood,

I have gone through your sample XML schema file and generated source files. A quick solution is to slightly modify complexType "RootElementType" element, as shown in the below snippet.

<xs:complexType name="RootElementType">
  <xs:sequence>
    <xs:element name="Element"  type = "ElementType" minOccurs="2" maxOccurs="2"/>
  </xs:sequence>
</xs:complexType>

Let me know if it solves your problem.

Regards, Nandkishor