I had written a small program to validate an XML using a DTD. When I am referring to the DTD in the XML file its giving an error. I learned that we can refer to the DTD in the XML file in 2 ways. The first way is working fine while the second way is not working as expected. I want to make my concepts clear so I want to learn to refer the DTD using both the ways. Please do find the code snippet below :
Please do help me in clearing my concepts. Please do explain me why I am getting an exception in the second case. As I understand both the methods should work.