Bob, Thanks for the test case. I'll take a look.
Dave On Tue, Nov 07, 2017 at 01:51:53PM -0800, Bob Barcklay wrote: > Hi Dave, > > Sorry for the delayed response. I just reran the test on the latest code > from bitbucket. The issue occurs when I import the xmldsig schema from > within another schema. I’ve created a simple test schema that only imports > the xmldsig schema and do see the problem. If I run generateDS on the > xmldsig schema directly (no importing), I get the results you describe. > > > > > -Bob > > > > On Nov 3, 2017, at 4:19 PM, Dave Kuhlman <dkuhl...@davekuhlman.org> wrote: > > > > Bob, > > > > I ran generateDS.py against the XML schema you sent me. > > > > In class ReferenceType, I get this generated code for exportChildren: > > > > def exportChildren(self, outfile, level, namespace_='ds:', > > name_='ReferenceType', fromsubclass_=False, pretty_print=True): > > if pretty_print: > > eol_ = '\n' > > else: > > eol_ = '' > > if self.Transforms is not None: > > self.Transforms.export(outfile, level, namespace_='ds:', > > name_='Transforms', pretty_print=pretty_print) > > if self.DigestMethod is not None: > > self.DigestMethod.export(outfile, level, namespace_='ds:', > > name_='DigestMethod', pretty_print=pretty_print) > > if self.DigestValue is not None: > > showIndent(outfile, level, pretty_print) > > outfile.write('<%sDigestValue>%s</%sDigestValue>%s' % > > (namespace_, self.gds_format_base64(self.DigestValue, > > input_name='DigestValue'), namespace_, eol_)) > > > > In the header line of this function, the namespace_ parameter gets > > the default value 'ds:', whereas in your generated code (below) it > > has the value 'oadr:'. Am I right that the above code would handle > > your issue correctly? I've attached my generated file (which I > > swear that I did not manually doctor. Honest.) to a separate email. > > > > So, why is your generated code different from mine? > > > > Is it possible that we are using different versions of > > generateDS.py? You can look at the top of that generated file to > > find the version. You can also see, near the top of the file, what > > command line and options I used to generate it. > > > > If you suspect that this problem is happening because your version > > is different from mine, you can find the latest version (which I am > > using) at https://bitbucket.org/dkuhlman/generateds > > <https://bitbucket.org/dkuhlman/generateds>. > > > > And, if it is not the version, then perhaps you could show me what > > command line you used to generate your code (or send me the file, > > since it has the command line options at the top). Perhaps there is > > some option that is causing the problem. I tried several different > > command lines, but they produced the same thing. I tried the > > following command lines: > > > > $ ./generateDS.py -f -o "tmp01sup.py" -s "tmp01sub.py" > > --super="tmp01sup" --member-specs="dict" xmldsig-core-schema.xsd > > $ ./generateDS.py -f -o "tmp2.py" xmldsig-core-schema.xsd > > > > And, I get the same thing whether I use Python 2.7 or Python 3.6. > > > > I need a clue. Hope your weekend is/was a good one. > > > > Dave > > > > On Wed, Nov 01, 2017 at 05:09:56PM -0700, Bob Barcklay wrote: > >> Hi Dave, > >> > >> I’m using the XML Signature Schema > >> (http://www.w3.org/2000/09/xmldsig#) imported and used inside > >> another schema (http://openadr.org/oadr-2.0b/2012/07) to create a > >> “signed object”. I’m running into a problem with the namespace that > >> is generated for one element within the XML Signature. Everything > >> else looks fine but this one element, which should get associated > >> with the XML Digital Signature namespace is instead getting tagged > >> with the surrounding namespace. The XSD look fine: > >> > >> > >> <element name="Reference" type="ds:ReferenceType"/> > >> <complexType name="ReferenceType"> > >> <sequence> > >> <element ref="ds:Transforms" minOccurs="0"/> > >> <element ref="ds:DigestMethod"/> > >> <element ref="ds:DigestValue"/> > >> </sequence> > >> <attribute name="Id" type="ID" use="optional"/> > >> <attribute name="URI" type="anyURI" use="optional"/> > >> <attribute name="Type" type="anyURI" use="optional"/> > >> </complexType> > >> > >> The DigestValue element is associated with the ‘ds’ namespace just > >> like Transforms and DigestMethod, but the generated code for this > >> element looks different. > >> > >> def exportChildren(self, outfile, level, namespace_='oadr:', > >> name_='ReferenceType', fromsubclass_=False, pretty_print=True): > >> if pretty_print: > >> eol_ = '\n' > >> else: > >> eol_ = '' > >> if self.Transforms is not None: > >> self.Transforms.export(outfile, level, namespace_='ds:', > >> name_='Transforms', pretty_print=pretty_print) > >> if self.DigestMethod is not None: > >> self.DigestMethod.export(outfile, level, namespace_='ds:', > >> name_='DigestMethod', pretty_print=pretty_print) > >> if self.DigestValue is not None: > >> showIndent(outfile, level, pretty_print) > >> outfile.write('<%sDigestValue>%s</%sDigestValue>%s' % (namespace_, > >> self.gds_format_base64(self.DigestValue, input_name='DigestValue'), > >> namespace_, eol_)) > >> Notice that both Transforms and DigestMethod are exported with > >> namespace_=‘ds:’ but for some reason, DigestValue is exported with > >> the default namespace for exportChildren which in this case is > >> namespace=‘oadr:’. The generated code looks similar if I process > >> only the XML Signature XSD but in this case, the default namespace > >> is ‘ds:’ so it generates correctly. > >> > >> I’ve tried unsuccessfully to isolate just a portion of the XSD to > >> make this happen but haven’t been able to do it. I’m attaching the > >> XML Signature XSD which can be used to generate code that will > >> exhibit the behavior described above. I’m happy to experiment > >> further if you can’t point me in the right direction ;-) > >> > >> BTW, I am able to work around the issue by hand editing the > >> generated code and replacing namespace_ with ‘ds:’. > >> > >> -Bob > >> > >> > >> > >> > >> > >> > >> b...@kisensum.com > >> (510) 520-7741 > >> www.kisensum.com <http://www.kisensum.com/> <http://www.kisensum.com/ > >> <http://www.kisensum.com/>> > >> > >> Kisensum | 344 Thomas Berkley Way #260 | Oakland, CA, 94612 > >> > > > >> ------------------------------------------------------------------------------ > >> Check out the vibrant tech community on one of the world's most > >> engaging tech sites, Slashdot.org <http://slashdot.org/>! > >> http://sdm.link/slashdot <http://sdm.link/slashdot> > > > >> _______________________________________________ > >> generateds-users mailing list > >> generateds-users@lists.sourceforge.net > >> <mailto:generateds-users@lists.sourceforge.net> > >> https://lists.sourceforge.net/lists/listinfo/generateds-users > >> <https://lists.sourceforge.net/lists/listinfo/generateds-users> > > > > > > -- > > > > Dave Kuhlman > > http://www.davekuhlman.org <http://www.davekuhlman.org/> -- Dave Kuhlman http://www.davekuhlman.org ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users