import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.parsers.*;
import java.io.*;

public class LocateError{

	public static void main(String[] args) throws IOException{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		System.out.print("Enter XML file name:");
		String xmlFile = bf.readLine();
		LocateError par = new LocateError(xmlFile);
	}
	
	public LocateError(String str){
		try{
			File file = new File(str);
			if (file.exists()){
				XMLReader reader = XMLReaderFactory.createXMLReader();
				reader.parse(str);
				System.out.println(str + " is well-formed!");
			}
			else{
				System.out.println("File not found: " + str);
			}
		}
		catch (SAXParseException sax){
			System.out.println(str + " isn't well-formed");
			int line = sax.getLineNumber();
			int col = sax.getColumnNumber();
			System.out.println("Error is at line number "+ line + " and Column position "+ col);
		}
		catch (SAXException sax){}
		catch (IOException io){
			System.out.println(io.getMessage());
		}
	}
}