On Sat, Sep 13, 2014 at 04:55:27PM +0200, Per Rosengren wrote: > With model.xsd defining version as a list of ints: > > ------------ > <?xml version="1.0" encoding="UTF-8"?> > <xs:schema targetNamespace="http://www.neonode.com/platform" > elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns="http://www.neonode.com/platform"> > > <xs:element name="version" type="valuelist"></xs:element> > > <xs:simpleType name="valuelist"> > <xs:list itemType="xs:nonNegativeInteger" /> > </xs:simpleType> > </xs:schema> >
The difficulty with this schema is that generateDS.py needs to be able to generate a class to represent the container for the list of integers. It needs an xs:complexType (or an xs:element that is defined as an xs:complexType. Here is a modified version of your schema that generates code that will successfully parse and export your XML instance document (model_dedes.xml). <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://www.neonode.com/platform" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.neonode.com/platform"> <xs:element name="project" type="containerType"/> <xs:complexType name="containerType"> <xs:sequence> <xs:element name="version" type="valuelist"/> </xs:sequence> </xs:complexType> <xs:simpleType name="valuelist"> <xs:list itemType="xs:nonNegativeInteger" /> </xs:simpleType> </xs:schema> When I generate code from the above XML schema and then run that code, I see the following: $ ./run_test tmp03 test02.xsd + ./generateDS.py -f -o tmp03sup.py -s tmp03sub.py --super tmp03sup --member-specs=dict --export=write test02.xsd $ python tmp03sup.py model-dedess.xml <?xml version="1.0" ?> <project> <version>0 1</version> </project> There was one error in generateDS.py related to this. On export, it was failing to convert the list of values to single string with the individual values separated by blanks. Basically, it needed to do "' '.join(data)", but was not. I've fixed that and have pushed the change to Bitbucket -- https://bitbucket.org/dkuhlman/generateds So, here is a question: Will that kind of modification to your XML schema be acceptable to you and will it fit your needs? If so, I believe I've solved your problem. If not, we have to do more thinking on this. Either way, please let me know. Dave > ---------------- > > Generate with generateDS 2.13a from PyPI under Windows 7 Python 2.7.3 32 > bit: > > generateds.py -o model.py ../model.xsd > > > With the following model-dedes.xml: > ---------------- > > <?xml version="1.0" encoding="UTF-8"?> > <project xmlns="http://www.neonode.com/platform" xmlns:xsi=" > http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.neonode.com/platform model.xsd "> > <version>0 1</version> > </project> > > ----------------- > > Running Python script: > > import model > model.parse("model-redes.xml", silence=True) > > results in: > > Traceback (most recent call last): > File "C:\Users\per.rosengren\code\targetplatformv7\generator\run.py", > line 132, in <module> > p = model.parse("model-redes.xml", silence=True) > File "C:\Users\per.rosengren\code\targetplatformv7\generator\model.py", > line 1230, in parse > rootObj.build(rootNode) > File "C:\Users\per.rosengren\code\targetplatformv7\generator\model.py", > line 720, in build > self.buildChildren(child, node, nodeName_) > File "C:\Users\per.rosengren\code\targetplatformv7\generator\model.py", > line 735, in buildChildren > raise_parse_error(child_, 'requires integer: %s' % exp) > File "C:\Users\per.rosengren\code\targetplatformv7\generator\model.py", > line 485, in raise_parse_error > raise GDSParseError(msg) > model.GDSParseError: requires integer: invalid literal for int() with base > 10: '0 1' (element {http://www.neonode.com/platform}version/line 5) -- Dave Kuhlman http://www.davekuhlman.org ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users