Carlos, If I recall correctly, I made that change in order to prevent name spaces from being unnecessarily defined again and again in child elements. Since name space definitions cascade to child elements, that would be excessive clutter.
Apparently, that change needs some fine tuning. Thanks for the report and the example. I believe that I've been able to reproduce the error you have reported. I'll work on it. I'm not sure how hopeful we can be. Seems like I've tried to fix this error several times before. Maybe this time ... Give me a day or two. Dave On Sun, Jun 09, 2019 at 11:27:21AM +0100, Carlos AG wrote: > Hi, > > I am not sure where is the best place to ask this question about using a > file I created with generateDS. If this is not the right place, > apologies and I would appreciate to be told where to post it. > > I am having the following problem: when I generate the xml using the > export function, the children elements are missing the namespace. > > I have been using a file created with Python 2.7.14 and GenerateDS > 2.29.6 and everything was working well, this was my exported xml: > > > <oadr:oadrSignedObject xmlns:oadr="http://openadr.org/oadr-2.0b/2012/07"> > > <oadr:oadrCreatedEvent > > xmlns:oadr="http://openadr.org/oadr-2.0b/2012/07" > > xmlns:pyld="http://docs.oasis-open.org/ns/energyinterop/201110/payloads" > > > <pyld:eiCreatedEvent > > xmlns:oadr="http://openadr.org/oadr-2.0b/2012/07" > > xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110" > > xmlns:pyld="http://docs.oasis-open.org/ns/energyinterop/201110/payloads"> > > <ei:eiResponse > > xmlns:oadr="http://openadr.org/oadr-2.0b/2012/07" > > xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110" > > xmlns:pyld="http://docs.oasis-open.org/ns/energyinterop/201110/payloads" > > > <ei:responseCode>200</ei:responseCode> > > </ei:eiResponse> > > <ei:eventResponses > > xmlns:oadr="http://openadr.org/oadr-2.0b/2012/07" > > xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110"> > > <ei:eventResponse > > xmlns:oadr="http://openadr.org/oadr-2.0b/2012/07" > > xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110" > > xmlns:pyld="http://docs.oasis-open.org/ns/energyinterop/201110/payloads" > > > <ei:responseCode>200</ei:responseCode> > > <pyld:requestID>300</pyld:requestID> > > <ei:qualifiedEventID > > xmlns:oadr="http://openadr.org/oadr-2.0b/2012/07" > > xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110" > > > <ei:eventID>4</ei:eventID> > > > > <ei:modificationNumber>0</ei:modificationNumber> > > </ei:qualifiedEventID> > > <ei:optType>none</ei:optType> > > </ei:eventResponse> > > </ei:eventResponses> > > <ei:venID>1</ei:venID> > > </pyld:eiCreatedEvent> > > </oadr:oadrCreatedEvent> > > </oadr:oadrSignedObject> > > > But I have recently generated a new file with python 3.7 and generateDS > 2.32.0. This is the xml (note the missing namespaces in the children > element) > > > <oadrSignedObject xmlns:oadr="http://openadr.org/oadr-2.0b/2012/07"> > > <oadr:oadrCreatedEvent> > > <pyld:eiCreatedEvent> > > <ei:eiResponse> > > <responseCode>200</responseCode> > > </ei:eiResponse> > > <ei:eventResponses> > > <eventResponse> > > <responseCode>200</responseCode> > > <requestID>300</requestID> > > <ei:qualifiedEventID> > > <eventID>4</eventID> > > <modificationNumber>0</modificationNumber> > > </ei:qualifiedEventID> > > <optType>none</optType> > > </eventResponse> > > </ei:eventResponses> > > <venID>1</venID> > > </pyld:eiCreatedEvent> > > </oadr:oadrCreatedEvent> > > </oadrSignedObject> > > > When trying to *etree_.fromstring* the oadrSignedObject I get the error: > "Namespace prefix pyld on eiCreatedEvent is not defined" > > After digging in the generateDS files I can see that the problem is in > the *exportChildren()* methods and how they call the export methods of > the children elements: > > * In the old file: > > self.oadrCreatedEvent.export(outfile, level, namespace_='oadr:', > name_='oadrCreatedEvent', pretty_print=pretty_print) > > * In the new file: > > self.oadrCreatedEvent.export(outfile, level, > *namespaceprefix_='oadr:', namespacedef_=''*, > name_='oadrCreatedEvent', pretty_print=pretty_print) > > In the new file we are passing *namespaceprefix_ *and *namespacedef_* > which overwrite the default ones used in the child's export method, if > they were not passed everything would work well. > > The only thing I have tried to do to sort the problem was to create my > file again using the *--no-namespace-defs* but what that does is the no > name space is added at all. > > Does anybody know what should I do to get the namespace in the child > elements. > > Thank you very much in advance. > > Carlos > > ** > -- > > Carlos Alonso-Gabizon - Carbon Co-op - Technical Developer > > m: 07990 725 966 > > e: car...@carbon.coop > w: https://carbon.coop > t: @carboncoop > > People Powered Not Fossil Fuelled: an intro to Carbon Co-op: > http://www.carbon.coop/reports/CarbonCoopPeoplePoweredBooklet.pdf > > Office: c/o URBED, 10 Little Lever Street, Manchester M1 1HR > > Society for the Reduction of Carbon Ltd (Trading as Carbon Co-op) > Registered address: Holyoake House, Hanover Street, Manchester M60 0AS United > Kingdom > Registered under the Industrial and Provident Societies Act 1965 > Registration Number 31342R > > _______________________________________________ > generateds-users mailing list > generateds-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/generateds-users -- Dave Kuhlman http://www.davekuhlman.org _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users