
//Standard JDK imports
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.net.URL;
import java.util.Properties;

// JDOM Specific Imports
import org.apache.xerces.parsers.SAXParser;
import org.apache.xerces.parsers.DOMParser;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.w3c.dom.Document;
import java.io.IOException;

public class XMLTest1
{
	/** Placeholder to store error code in case error occurs */
	private String sErrorCode;

	/** Placeholder to store error string in case error occurs*/
	private String sErrorCause;

	/** Fileoutputstream to write XML to disk*/
	private FileOutputStream fout;

	/** Outputter to output XML file to disk */
//	private XMLOutputter outputter=new XMLOutputter();;

	/** Location where the xml file should be written on the disk */
	private String sXmlPath;

	/** JDOM SaxBuilder */
	private DOMParser domBuilder;

	/** Is debug mode enabled */
	private boolean isDebugEnabled = false;


	public static void main(String args[])
	{


		new XMLTest1();

	}

	public XMLTest1()
	{
		sXmlPath = "Test.xml";
		try
		{
				domBuilder = new DOMParser();
				//domBuilder.setValidation(true);

				domBuilder.setFeature("http://apache.org/xml/features/validation/schema",true);
				domBuilder.setFeature("http://xml.org/sax/features/namespaces",true);
				domBuilder.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation","http://www.nith.com file:///D:/test/xmltest/Product.xsd");
				//domBuilder.setFeature("http://xml.org/sax/features/validation",true);

				//domBuilder.setFeature("http://apache.org/xml/features/validation/dynamic",true);

				domBuilder.parse(sXmlPath);

				Document 	document = domBuilder.getDocument();
				System.out.println(document.getDocumentElement().getTagName());
		}
		catch(Exception domex)
		{
			sErrorCode = "16777217";
			sErrorCause = domex.getMessage();
			System.out.println("excp "+domex);
			System.exit(0);
		}

	}

}
