read or write metadata from a newer ADM standard, or during development of new standards
read or write custom metadata that extends existing ADM structures e.g. custom parameters
read or write custom metadata that lives in AXML but outside of existing structures, e.g. tool version information
Implementation ideas:
1) extend all ADM elements with xml attributes, and use it to (optionally) store a reference to the corresponding XML elements when parsing or generating XML
when reading, this can be used to extract extra data from the xml
when writing, extra data can be injected into the XML before it's string-ified
bad: feels like writing an ADM document shouldn't modify it
bad: slightly increases storage even when not used
2) allow customisation of the XML to python class mapping
need to be able to tell parser "when dealing with element X, use this parser and this class"
need to be able to tell generator "when dealing with this class, use this un-parser"
bad: exposes innards of XML parser to users
bad: quite complex to do, especially for block formats. XML parser is already complex enough
3) when parsing or generating XML, produce a mapping from ADM objects to XML elements
question: how to store this mapping?
{id(adm_element): xml_element}
{id(adm_element): (adm_element, xml_element)}
{IDCompare(adm_element): xml_element} where IDCompare is a class that makes an object hashable and comparable by identity
some hack to make WeakKeyDictionary work with non-hashable types. It's not clear if weak references are really needed
could pass a list into the parser / generator to say which types we want to store
could be combined with 2, allowing the user to specify their own sub-classes, but keep parsing / generation external. It should be possible to re-use the parsing infrastructure externally, but this still allows the internal structure to be modified.
Use cases:
Implementation ideas: 1) extend all ADM elements with
xml
attributes, and use it to (optionally) store a reference to the corresponding XML elements when parsing or generating XML{id(adm_element): xml_element}
{id(adm_element): (adm_element, xml_element)}
{IDCompare(adm_element): xml_element}
whereIDCompare
is a class that makes an object hashable and comparable by identityWeakKeyDictionary
work with non-hashable types. It's not clear if weak references are really neededAfter writing this I think 3 is the way to go.