-
Notifications
You must be signed in to change notification settings - Fork 12
Description
I don't want to be pessimistic, but IMHO xml namespaces are a hard beast: you can mix nested default namespaces with named namespaces, making everything difficult to grasp at a first look for a human being. Unfortunately, I think that namespaces could be difficult to implement with a strong type system, but on the other hand in Rust we have powerful tools in our belt.
Do you think that implementing xml namespaces in strong-xml could be achieved in an appropriate amount of time (I explicitly wanted to avoid the short term)? Is it doable for the project or it is out of scope, at least for now?
Now, here some possible issues that come to my mind.
Each struct deriving XmlRead and XmlWrite is independent from their parent (if A contains b: B, B is still independent from A), but during read and write process, the namespaces are inherited from parent structs (I don't like to use parent/child terminology, which reminds OO polymorphism, but you get the idea in this context). Let's hypothesize that A contains c: C, and B contains c: C, but A and B have different default namespaces; what's the intended behavior of C in the two different contexts? The user would expect that both the namespaces of A and B have the same inner structure (represented by C), therefore the namespace of C would be inherited?
What's the best way to work with namespaces? From one point of view, each xml document can have a finite set of namespaces, therefore the simplest idea could be each namespace is an enum variant, and relative enum represents the set of namespaces. In this case it should be necessary to define a trait in order to make the enum usable as set of namespaces. I am still doubtful about this solution, because I am not sure if the approach could lead to some issue when working with different xml structures with different set of namespaces but with common structs.
Attribute namespaces should be handled? In theory it is possible to specify a namespace for each attribute, and I imagine that it is possible to pay for the feature only at compile-time, without any cost for attributes without explicit namespace (which is the common case). Am I right?
Said that, I would like to help implementing the feature, but at the same time I have a limited amount of time. Surely the author has a better understanding of the efforts required to implement xml namespaces. If this is doable and the amount of time I can invest could bring to something useful, then I will be happy to contribute.