title: Java approach for XML Validation
body: <p>I want to validate the xml tag values in java. </p>
  
  <p>Scenario:
        Suppose I have data as follow</p>
  
  <pre><code>ELements: element1, element2, element3, element4, element5
  Values: value1, value2, value3, value4, value5, value6, value7, value8
  
  Now following are the possible combinations which I have to validate:
    1. Element1 can have value1/value2 ( element1-&gt;value1/value2 )
    2. Element2 can have value3/value4 ( element2-&gt;value3/value4 )
    4. Element3 can have value5 if element1 has value1 ( element3-&gt;value5 if element1-&gt;value1 )
       else Element3 can have value6 if element1 has value2 ( element3-&gt;value6 if element1-&gt;value2 )
    5. Element4 can have value7 if element1-&gt;value1 and element2-&gt;value4
  </code></pre>
  
  <p>I can have hard-coding of the requirement in one java file but I want a flexible approach wherein if in future any new condition comes into picture then it can be easily added.</p>
  
  <p>I thought of Hibernate Validation but later on came to know that it is supported for Java 6 and above. My constraint is that I have to use Java 1.5</p>
  
  <p>Please suggest an appropriate approach to fulfill the above requirement. Any link suggestion would also work.</p>
  
  <p>Note: Schema validation is already being carried out.</p>