Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error validating the XML file against XSD file

843834Jan 17 2006 — edited Jan 18 2006
Hi all,
I have a XML file which is to be validated against a XSD file. I am able to know the error but could not able to catch that error.
Following the error message:-

Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 10 errors. Please call the setErrorHandler method to fix this.
Error: URI = "file:C:/TBWS-1.0/XMLProcessing/note.xml", Line = "4", : cvc-datatype-valid.1.2.1: 'xcf' is not a valid value for 'integer'.
Error: URI = "file:C:/TBWS-1.0/XMLProcessing/note.xml", Line = "4", : cvc-type.3.1.3: The value 'xcf' of element 'to' is not valid.

and here is my code:
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setValidating(true);
		factory.setNamespaceAware(true);

		//Set the XML Schema language against which this XML file is to validate
		factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
				"http://www.w3.org/2001/XMLSchema");

		factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "note.xsd");
		try
		{
			DocumentBuilder builder = factory.newDocumentBuilder();
			document = builder.parse(new File("note.xml"));
		} 
		catch (SAXException sxe) 
		{
			sxe.printStackTrace();
		}
		catch (ParserConfigurationException pce) 
		{
			pce.printStackTrace();
		}
		catch (IOException ioe) 
		{
			ioe.printStackTrace();
		}
Any help will be appriciable.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 15 2006
Added on Jan 17 2006
2 comments
557 views