944,122 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 6166
  • Java RSS
Apr 26th, 2005
-1

parsing error (XML file-java-schema)

Expand Post »
I've a problem with some code, this is the "core" of the code:

Java Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dakkar is offline Offline
14 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Interfaces
Next Thread in Java Forum Timeline: Which type of class is not instantiated?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC