Checking for valid child elements.
Hi there,
I am not if it is possible to check for valid child elements of a parent before processing the parent. to give an example as shown below where I regenerate the whole node-set of the parent (being test1, test2 etc) if the descendants are valid.
<ValidateDataTypes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Test1>
<string_20>apple</string_20>
<boolean_YN>yes</boolean_YN>
<decimal_3>12.456</boolean_YN>
</Test1>
<Test2>
<string_Nullable/>
<payment>
<decimal_2>25.78</decimal_2>
</payment>
</Test2>
<Test3>
<payment>
<decimal_2>125.789</decimal_2>
</payment>
</Test3>
</ValidateDataTypes>
the desired output should be
<ValidateDataTypes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Failed>
<string_20>string length is not 20</string_20>
<boolean_YN>only 1 char allowed</boolean_YN>
<decimal_3>12.456</boolean_YN>
</Failed>
<Test2>
<string_Nullable/>
<payment>
<decimal_2>25.78</decimal_2>
</payment>
</Test2>
<Failed>
<payment>
<decimal_2>only 2 decimal places allowed</decimal_2>
</payment>
</Failed>
</ValidateDataTypes>
thanks
|