parsing error (XML file-java-schema)

Reply

Join Date: Apr 2005
Posts: 13
Reputation: dakkar is an unknown quantity at this point 
Solved Threads: 0
dakkar dakkar is offline Offline
Newbie Poster

parsing error (XML file-java-schema)

 
-1
  #1
Apr 26th, 2005
I've a problem with some code, this is the "core" of the code:

  1. File xmldocFile = new File(xmlFile);
  2. File schemaFile = new File(xsdFile);
  3.  
  4. try
  5. {
  6. DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  7. dbf.setValidating(true);
  8. SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
  9. Schema mySchema = sf.newSchema(schemaFile);
  10. dbf.setSchema(mySchema);
  11.  
  12. DocumentBuilder db = dbf.newDocumentBuilder();
  13. ErrorChecker errors = new ErrorChecker();
  14. db.setErrorHandler(errors);
  15.  
  16. db.parse(xmldocFile);
  17. }
  18. catch (Exception e)
  19. {
  20. System.out.print("[Parsing]=================================================================");
  21. System.out.println("Error: " + e);
  22. System.out.print("==========================================================================");
  23. }




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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC