Monday, December 27, 2010

XML validate that all elements have same value

I have a payload like this:


alfa>3
beta>3
gamma>3
delta>3




and I need to validate that all "number" are the same within the same element... can be 3, can be anything else.

Now, with Schematron I doubt this is possible. With XSD neither. They all seem to be NOT oriented to operate on collections, the validation scope is the single element.

We need to come up with a different strategy.

I wish there was a DSL allowing me to state:

test: assert all /lines/line/number are same within /lines
with message: 'all line number must be same'

where we establish a scope (/lines), a predicate (are same), a subject (/lines/line/number) and a selection rule (all)

No comments: