logo       

Re: could not continue after fatal error--need urgent help: msg#00049

Subject: Re: could not continue after fatal error--need urgent help

Hi mukul and Michael,
 
sorry for this communication gap i was on vacation.well thanks for your time and reply...but problem is; In our system we need to capture all th well formed errors in one go. getting one fatal error is not acceptable as per our requirement.

it will be a great help if you can let me know where i am doing wrong for this (need urgent solution) or atleast let me know where can i find solution.
 
The (relevant portion of the) XML document follows:(with two well formed errors)***************
<?xml version="1.0" encoding="UTF-8"?>
<rootDirMapping>
    <rootDir>AppData</rootDir>
    <mappingFile>MappingFiles</mappingFile>
    <schemaFile>SchemaFiles<schemaFile>
    <validationHierarchy>1hierarchy<validationHierarchy>
    <database>database</database>
</rootDirMapping>
The (relevant portion of the) XML schema follows:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="rootDirMapping">
          <xs:complexType>
              <xs:sequence>
                    <xs:element name="rootDir" type="xs:string" />
                    <xs:element name="mappingFile" type="xs:string" />
                    <xs:element name="schemaFile" type="xs:string" />
                    <xs:element name="validationHierarchy" type="xs:string" />
                    <xs:element name="database" type="xs:string" />
              </xs:sequence>
          </xs:complexType>
    </xs:element>
</xs:schema>
*************************************************************
The (relevant portion of the) Java Code follows:
public static boolean validateWithSchema(String XMLFile, String Schema){
          boolean result = true;
          long startTime = System.currentTimeMillis();
          // Instantiate the DOM parser.
          DOMParser parser = new DOMParser();
          // set the features
          try{
          parser.setFeature("http://xml.org/sax/features/namespaces",true);
          parser.setFeature("http://xml.org/sax/features/validation",true);
          parser.setFeature("http://apache.org/xml/features/validation/schema",true);
          parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
          parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true);
          parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",Schema);
          // myErrorHandler is a descendant of ErrorHandler, it should be set here to be able to catch parse errors
          forgivingErrorHandler hndl = new forgivingErrorHandler();
          parser.setErrorHandler(hndl);
          } catch (SAXNotSupportedException ex){
                System.out.println("SAXNotSupportedException Exception");
          } catch (SAXNotRecognizedException ex){
                System.out.println("SAXNotRecognizedException Exception");
          }
          // parse the xml file, the errorhandler class has callbacks,
          // so those will be called automatically there is a parse error
          try{
                parser.parse(XMLFile);
              //System.out.println("Parsed Successfully by DOM Parser");
          } catch (org.xml.sax.SAXException ex){
                System.out.println("SAXException Exception");
              ex.printStackTrace();
          } catch (java.io.IOException ex){
                System.out.println("IOException Exception");
          }
          return result;
          }
The (relevant portion of the) Java Code for Error Handler follows:
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class forgivingErrorHandler implements org.xml.sax.ErrorHandler {
   
    public forgivingErrorHandler() {}
    public void error(org.xml.sax.SAXParseException err) throws SAXException {
          FileWriter fstream;
          try {
              String fs="D:\\WORKSPACE\\xmlValidation\\ExceptionLogs\\Errors.txt";
              fstream = new FileWriter(fs,true);
              PrintWriter out = new PrintWriter(fstream);
              out.write("Exception at:"+err.getLineNumber()+"***"+err.getMessage()+"\n\n\n");
              out.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
         
    }

    public void fatalError(org.xml.sax.SAXParseException fe) throws SAXException {
          FileWriter fstream;
          try {
              String fs="D:\\WORKSPACE\\xmlValidation\\ExceptionLogs\\FatalErrors.txt";
              fstream = new FileWriter(fs,true);
              PrintWriter out = new PrintWriter(fstream);
              out.write("Exception at:"+fe.getLineNumber()+"***"+fe.getMessage()+"\n\n\n");
              out.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
         
    }

    public void warning(org.xml.sax.SAXParseException war) throws SAXException {
          FileWriter fstream;
          try {
              fstream = new FileWriter("D:\\WORKSPACE\\xmlValidation\\ExceptionLogs\\Warnings.txt",true);
              PrintWriter out = new PrintWriter(fstream);
              out.write("Exception at:"+war.getLineNumber()+"***"+war.getMessage()+"\n\n\n");
              out.close();
          } catch (IOException e) {
              System.out.println("Here are we in the Warning section....");
              e.printStackTrace();
          }
         
    }
   
   
}

I have put xml-apis.jar, xercesImpl.jar, serializer.jar, resolver.jar at build path.

Unfortunately, when I try to validate the above XML document against the Schema, it throws errors as I explained above? only one fatal error.
Errors that I got*****************************
Exception at:8***The element type "validationHierarchy" must be terminated by the matching end-tag "</validationHierarchy>".

Exception at:8***The end-tag for element type "validationHierarchy" must end with a '>' delimiter.

Exception at:9***XML document structures must start and end within the same entity.

Exception at:-1***Premature end of file.
*************************

it will be a great help if you can let me know where i am doing wrong for this (need urgent solution) or atleast let me know where can i find solution.

Thanks
Vineet Rajput
Software Engineer
Snap-On Business Solution
Logix Techno Park,
Noida,INDIA














Best of Fares
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe