Search code examples
xmlconfigurationreferential-integritydata-integrityconsistency

Tools, rules or processes for checking internal consistency of XML config files


I've worked on projects that have very complex XML configuration, and one problem that's faced is maintaining the internal consistency of the XML.

In this case I don't mean the strict XML schema consistency, but rather the higher level relation between the nodes used. Most problems were caused by implicit linking between information encoded in the XML, and implicit relation of that information to the codebase. Examples might be:

  • XML node data implicitly linked to enums in code
  • Business objects in the same config that are related (in that they share information that needs to be consistent) without any explicit relation between them
  • Code in XML to be compiled and parsed at runtime

It struck me that a) this might become a practice of increasing frequency and b) that in some cases we're implicitly creating a new coding language that's not compile-time checked -- and in fact has few checks at all until it's run.

Is anyone else out there facing similar scenarios, and are there any tools or approaches that make the problem more tractable? I'd like some general examples that are technology-agnostic -- my own specific experience has been with C# and with config for proprietary systems.

Note: although I have an answer to this below, I've no intent of taking my own as the final answer.


Solution

  • This will greatly depend on languages/frameworks/tools you're using for your project.

    Using XML for configuration can be really problematic because it cannot be compile time checked.

    For example, when using Java and Spring Framework, there exists an Eclipse plugin called Spring Tool Suite which can do synchronization checking between XML configuration and the actual code.

    But this is just one example for a specific language and a specific framework. You should try to find out if something similiar exists for your scenario.

    By the way, if you let us know what technologies you're using, we might be able to assist you more.