Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element

    Hello,

    I'm pretty new in Java.
    I validate my xml againt xsd file, but this error org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element occurred.

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    	        factory.setValidating(true);
    	        factory.setNamespaceAware(true);
    	        factory.setAttribute(SCHEMA_LANGUAGE_ATTRIBUTE, XSD_SCHEMA_LANGUAGE);
    	        factory.setIgnoringComments(true);
    	        DocumentBuilder builder = factory.newDocumentBuilder();
    	        builder.setEntityResolver(new EntityResolver() {
    	            public InputSource resolveEntity(String publicId, String systemId){
    	            	return new InputSource(xsd);
    	            }
    	        });
     
    	        builder.setErrorHandler(new ErrorHandler() {
    	            public void error(SAXParseException exception) throws SAXException {
    	               exception.printStackTrace();
    	            }
    	            public void fatalError(SAXParseException exception)
    	                    throws SAXException {
    	            	exception.printStackTrace();
    	            }
    	            public void warning(SAXParseException exception)
    	                    throws SAXException {
    	            	exception.printStackTrace();
    	            }
    	        });
     
    	        builder.parse(xml);
    Last edited by eunmi; October 12th, 2011 at 04:29 AM. Reason: solved


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element

    Sorry,

    The problem was solved , some stupid mistakes.

Similar Threads

  1. What is the problem with this following declaration in JDK 1.4?
    By Senjuti in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 2nd, 2011, 11:37 AM
  2. Inner class initialization and declaration
    By longwu in forum Object Oriented Programming
    Replies: 2
    Last Post: August 31st, 2011, 07:44 AM
  3. [SOLVED] Constructor and declaration issues
    By Gthoma2 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 27th, 2011, 11:16 PM
  4. Variable declaration placement
    By 2nickpick in forum Java Theory & Questions
    Replies: 2
    Last Post: January 22nd, 2011, 11:34 AM
  5. how to find an element in an array
    By humdinger in forum Collections and Generics
    Replies: 8
    Last Post: April 9th, 2010, 05:22 PM