For example,
Xml document:
<some_document>
<elements>
<element>1</element>
<element>2</element>
<element>3</element>
</elements>
<sum>6</sum>
<some_document>
Rules(in some form, probably in xml), according to schema of given document:
Sum of all <element> fields must match the value in <sum> field
Result: Is document valid, according to rules specified or not?(in xml form too, probably)
So, I need a library that implements given functionality or at least points to dig in for writing one by myself. Language does not matter.