We have launched a free Basic Kubernetes Course. Click here to enrol now! Kubernetes is a container orchestration platform used by enterprises worldwide and Kubernetes developers are in high demand!
This article demonstrates the usage of
in handling warning during StAX parsing.
Create employee.dtd as shown below.
Note that the entity ‘commonAddress’ is defined twice in the DTD (see lines 5-6 below).
This will throw a warning condition during parsing.
Create employee.xml as shown below.
Create TestWarning as shown below.
Define a custom schema factory called ‘MyDTDSchemaFactory’ (lines 61-78 below).
and override the
method (see lines 80-90 below).
Instantiate ‘MyDTDSchemaFactory’ by passing ‘MyXMLReporter’ object (see line 27 below).
During parsing, a warning message shall be generated for duplicate entities in DTD and the message shall be passed via the callback method (see line 86 below).
The output of the program demonstrating handling of warning message is shown below.