DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   parsing error (XML file-java-schema) (http://www.daniweb.com/forums/thread22591.html)

dakkar Apr 26th, 2005 2:58 pm
parsing error (XML file-java-schema)
 
I've a problem with some code, this is the "core" of the code:

File xmldocFile = new File(xmlFile);
              File schemaFile = new File(xsdFile);

              try
              {
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                dbf.setValidating(true);
                SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
                Schema mySchema = sf.newSchema(schemaFile);
                dbf.setSchema(mySchema);

                DocumentBuilder db = dbf.newDocumentBuilder();
                ErrorChecker errors = new ErrorChecker();
                db.setErrorHandler(errors);

                db.parse(xmldocFile);
              }
              catch (Exception e)
              {
                    System.out.print("[Parsing]=================================================================");
                    System.out.println("Error: " + e);
                    System.out.print("==========================================================================");
              }




and this is the output error when I run it on a couple of example files:


H:\_java_prove_>java SchemaTest xeno08x.xml xeno08x.xsd
XML File:xeno08x.xml
XSD File:xeno08x.xsd
=> Line [2] -----------------------------------
Document root element "record", must match DOCTYPE root "null".
-----------------------------------------------------------------------
=> Line [2] -----------------------------------
Document is invalid: no grammar found.
-----------------------------------------------------------------------
=> Line [2] -----------------------------------
http://www.w3.org/TR/xml-schema-1#cv...i:noNamespaceS
chemaLocation
-----------------------------------------------------------------------
=> Line [2] -----------------------------------
http://www.w3.org/TR/xml-schema-1#cv...i:noNamespaceS
chemaLocation
-----------------------------------------------------------------------


I've tried various changes, but I don't find the error :_(

Can anyone help me?

TYIA


All times are GMT -4. The time now is 4:00 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC