In this article, we shall demonstrate how details of validation error can be obtained by using
Create the employee.dtd as shown below.
It defines the employee element that contains id, name and salary sub-elements.
Create invalidEmployee.xml as shown below. Note that it is
in accordance with employee.dtd described above as it defines the ‘title’ element (see line 4 below) instead of ‘salary’ element.
Create TestValidationProblem class as shown below.
(see lines 36-46 below).
When validation related exception is thrown, explore the details extracting
from the exception (see line 37 below).
The detailed error message and its Location can be further extracted from
(see lines 38-39 below).
The output of the program demonstrating the usage of
is shown below: