954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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#cvc-complex-type.3.2.2?record&xsi:noNamespaceS
chemaLocation
-----------------------------------------------------------------------
=> Line [2] -----------------------------------
http://www.w3.org/TR/xml-schema-1#cvc-complex-type.3.2.2?record&xsi:noNamespaceS
chemaLocation
-----------------------------------------------------------------------


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

Can anyone help me?

TYIA

dakkar
Newbie Poster
14 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You