Update of code according to a change in the xsd scheme
Closed this issue · 7 comments
Hi,
I wrote in Python a writer and a reader for xml messages based on (1) an xsd schema provided by a third-party and (2) the Python bindings provided by the PyXB library.
I may receive in the future a new version of this xsd schema.
How can I avoid hard-coding the implementation of any change in the xsd schema within my xml writer and reader? At least what is the simplest way to include a change in the xsd schema within an xml writer/reader?
Many thanks in advance for your help and advice.
Graziella
I don't really have any suggestions, since it depends to a large degree on how the schema changes.
- Will the new schema use a different namespace?
- Are changes simply providing explicit definitions for new elements and attributes that are already permitted through wildcards in the existing schema?
- Is use of the changes indicated through a version attribute in the document?
In the worst case (the answer to all three is "no") it may not be possible, or at least will be very ad hoc.
If the namespace changes or an extension namespace is added you'll need to generate a new set of bindings for it. When you load the bindings into the Python application the parsing should just work automatically as long as the instance documents identify the namespaces correctly. Whatever the reader/writer needs to do that's specific to the content (anything you wrote yourself for the original schema) would have to be updated, but that probably couldn't be automated anyway.
It's possible: when the schema are parsed to generate the bindings, there is a complex data structure that contains all the information from it. You could use that capability to read both schema and compare them. Unless the schema are huge it'd probably be easier to compare them by hand.
Closing since there is no bug here and no enhancements planned.