Working
with XML document using java requires you to follow certain coding practices
so that your program does what it is intended for. Validation of an
XML document that is worked upon is necessary in most of the applications.
_______________________________________________
When you
validate an XML document you must make sure that the errors in the XML
document are registered with the error handler. Using an XML schema
is the better way to validate an XML document.
In most
of the XML document the schema that is referred to is found in the XML
document itself. Such methods are risky. Hence it is better to reference
the schema from the program itself.
If you
use the schema reference from the XML file, chances are there that the
file might refer to an incorrect schema that is needed in your program.
But the validation would pass through for the XML file, but this kind
of validation is not needed.
So set
the schema source through the schema property in the document namespace
in the program itself. This is the better way to deal with validation
of the XML document. Similarly there are many other coding practices
that need to be taken care of while using JAXP.
A simple
search would reveal a lot of information on coding practices and you
can find some of them in the URL, http://www.ibm.com/developerworks/xml/library/x-wxxm32.html.