Closed malicz closed 6 years ago
You need to be familiar with the content of the schemas to use PyXB effectively.
IssueDateType is derived from {urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2}DateType
, which is a complex type with simple content derived from {http://www.w3.org/2001/XMLSchema}date
. It is not a string. Its value is an instance of a binding class that extends Python's date
type.
print('Invoice IssueDate: ' + str(simple_invoice.IssueDate.value()))
print('Invoice IssueDate: ' + simple_invoice.IssueDate.value())
produces
Invoice IssueDate: 2011-09-22 00:00:00
Traceback (most recent call last):
File "issue102.py", line 8, in <module>
print('Invoice IssueDate: ' + simple_invoice.IssueDate.value())
TypeError: cannot concatenate 'str' and 'date' objects
which is correct behavior.
Thank you for your reply and off course for this powerful library. I understood the complex types but I did not see a way to call the date object from the IssueDateType. In the generated code I saw:
IssueDate = property(__IssueDate.value, __IssueDate.set, None, None)
So the value() was already called, using the debugger to inspect the object brought some confusion so then I asked.
Everything is working now, so thank you again
Any complex type that has simple content provides access to the content through the value()
method. This allows attributes to be accessed through other properties.
You're welcome.
Hi,
What I did:
the code to call it:
This results in:
TypeError: cannot concatenate 'str' and 'IssueDateType' objects
With the pycharm debugger I have looked into the objects and I cannot find the "2011-09-22" stored anywhere. This is a complex schema.
Did i miss anything?