Reputation: 14441
I was considering using xml namespaces in my configuration file. If I tag the config file content using a namespace then options for a program version are identified.
Is there a way to select all the nodes with a specific namespace version number and lower? This allows any version of the app to read any version configuration file without change.
Example:
<ns1:config xmlns:ns1="version 1.0">
<ns1:somesetting>blah</ns1:somesetting>
<ns2:SomeNewSetting xmlns:ns2="version 2.0">foob</ns2:SomeNewSetting>
</ns1:config>
Version 1 of the app selects namespace = "version 1.0".
Version 2 of the app selects namespace = "version 1.0" or namespace = "version 2.0".
Is there are better method than the brute force solution?
Upvotes: 0
Views: 111
Reputation: 163262
Using namespaces to manage versioning of an XML vocabulary is generally considered a bad idea. One of the reasons is well illustrated by your question: namespaces are not ordered. It's much better to use a version attribute. Dynamic selection of elements based on the value of an attribute is much easier than dynamic selection by namespace.
Upvotes: 1