corpus-services  1.0
CmdiXsdErrorReportGenerator.java
Go to the documentation of this file.
1 
10 package de.uni_hamburg.corpora.validation;
11 
12 
14 import org.xml.sax.SAXException;
15 import org.xml.sax.SAXParseException;
16 import org.xml.sax.ErrorHandler;
17 
24 public class CmdiXsdErrorReportGenerator implements ErrorHandler {
25 
26  // store latest file name for laughs
27  private String currentFileName;
28  private Report stats;
29  final String CMDI_XSD = "cmdi-validate-xsd";
30 
35  super();
36  stats = new Report();
37  }
38 
39  public Report getErrors() {
40  return stats;
41  }
42 
46  private void storeException(SAXParseException saxpe) {
47  String msg = saxpe.getMessage();
48  if (msg.contains("cvc-enumeration-valid") &&
49  msg.contains("xml;format-variant")) {
50  stats.addNote(CMDI_XSD, "Acceptable validation error in mimetypes: "
51  + "xml format variants");
52  } else if (msg.contains("cvc-complex-type") &&
53  msg.contains("MimeType")) {
54  stats.addNote(CMDI_XSD, "Acceptable validation error in mimetypes: "
55  + "xml format variants");
56  } else {
57  stats.addException(CMDI_XSD, saxpe,
58  "It's a validation error! (unrecognised):" +
59  saxpe.getMessage());
60  }
61  }
62 
67  public void fatalError(SAXParseException saxpe) throws SAXException {
68  storeException(saxpe);
69  }
70 
75  public void error(SAXParseException saxpe) throws SAXException {
76  storeException(saxpe);
77  }
78 
83  public void warning(SAXParseException saxpe) throws SAXException {
84  storeException(saxpe);
85 
86  }
87 }
88 
void addNote(String statId, String description)
Definition: Report.java:245
void addException(Throwable e, String description)
Definition: Report.java:287