I don't know much about Schema. But what you are saying is, if you declare your mainTag element to be in the default namespace then the XML validates, and if you declare it to be in no namespace, then it doesn't validate.
And I observe that your schema has a targetNamespace attribute whose value just happens to be the same as the default namespace URI which makes the XML validate.
So if this were my problem, I would go to my Schema reference material and find out what the targetNamespace attribute was supposed to do and what would happen if I left it out.
Also these xsd and xml are third-party's files and I have only the Java program which need to tailored to fit those guys. And the given xsd and xml properly validates with the XMLSpy. I am wondering is there anything which can change the attributes in the above java program to fit those guys and validate properly. Still wondering [ August 21, 2008: Message edited by: joshuaa ]