Hello,
just updated from 2.29.24 to 2.30.8 and discovered a maybe bug in the export
function.
2.29.24
was: def export(self, outfile, level, namespaceprefix_='', name_='Target',
namespacedef_='', pretty_print=True):
2.30.8
is: def export(self, outfile, level, namespaceprefix_='', namespacedef_='',
name_='Target', pretty_print=True):
well Ok, change of the parameter order, but there must be something wrong:
test code:
requestID = Natparas2.RequestID('DE','045','1234567')
dt = datetime.datetime.now().replace(microsecond=0)
localtime = dt.astimezone(pytz.timezone("Europe/Berlin"))
timestamp = str(localtime).replace("
","").replace("-","").replace(":","")
cSPID = '49045'
retainedDataHeader = Natparas2.RetainedDataHeader(requestID, cSPID,
timestamp)
requestAcknowledgement = Natparas2.RequestAcknowledgement()
retainedDataPayload = Natparas2.RetainedDataPayload(None,
requestAcknowledgement)
testxml =
Natparas2.RetainedDataMessage('0.4.0.2.3.0.14',retainedDataHeader,
retainedDataPayload)
output = StringIO()
output.write('<?xml version="1.0" encoding="UTF-8"?>\n')
testxml.export(output, 0, '', 'retainedDataMessage')
From 2.29.24:
<?xml version="1.0" encoding="UTF-8"?>
<retainedDataMessage xmlns="http://uri.etsi.org/02657/v1.18.1#/RetainedData">
<rdHeaderId>0.4.0.2.3.0.14</rdHeaderId>
<retainedDataHeader>
<requestID>
<countryCode>DE</countryCode>
<authorisedOrganisationID>045</authorisedOrganisationID>
<requestNumber>1234567</requestNumber>
</requestID>
<cSPID>49045</cSPID>
<timeStamp>20181210101011+0100</timeStamp>
</retainedDataHeader>
<retainedDataPayload>
<requestAcknowledgement/>
</retainedDataPayload>
</retainedDataMessage>
as it sould be.
Note: using default ns for RetainedDataMessage:
GenerateDSNamespaceDefs = {
"RetainedDataMessage":
'xmlns="http://uri.etsi.org/02657/v1.18.1#/RetainedData"',
}
defined only for the xml tag < RetainedDataMessage> and as the output shows,
it is only printed in line 2 of the output.
All other xml tags are without NS.
From 2.30.8:
<?xml version="1.0" encoding="UTF-8"?>
<RetainedDataMessage xmlns="http://uri.etsi.org/02657/v1.18.1#/RetainedData">
<rdHeaderId>0.4.0.2.3.0.14</rdHeaderId>
<retainedDataHeader xmlns="http://uri.etsi.org/02657/v1.18.1#/RetainedData">
<requestID xmlns="http://uri.etsi.org/02657/v1.18.1#/RetainedData">
<countryCode>DE</countryCode>
<authorisedOrganisationID>045</authorisedOrganisationID>
<requestNumber>1234567</requestNumber>
</requestID>
<cSPID>49045</cSPID>
<timeStamp>20181210102515+0100</timeStamp>
</retainedDataHeader>
<retainedDataPayload
xmlns="http://uri.etsi.org/02657/v1.18.1#/RetainedData">
<requestAcknowledgement
xmlns="http://uri.etsi.org/02657/v1.18.1#/RetainedData"/>
</retainedDataPayload>
</RetainedDataMessage>
Difference:
ALL other xml tags get the defaultNS which is wrong here, because only
<RetainedDataMessage> shall have it.
All other xml tags should go without defaultNS.
Code compare shows:
in 2.29.24:
self.exportChildren(outfile, level + 1, namespaceprefix_='', name_='Target',
pretty_print=pretty_print)
in 2.30.8:
self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_,
name_='Target', pretty_print=pretty_print)
here the namespacedef_ is added, but if the children is another xml tag with
another name like <retainedDataHeader>, and the defaultNS ist
wrong here because it is not valid and only valid for <RetainedDataMessage>.
So it must be checked in advance if it is valid here or not and if is defined
for the given tag name.
Please fix it 😉
Perhaps either roll back to the old behaviour or please implement a name check
in the children print function
to check if the children xml tag name hat got a defaultNS defined for its tag
name.
Regards,
Bernd
_______________________________________________
generateds-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/generateds-users