10 package de.uni_hamburg.corpora.validation;
17 import java.io.IOException;
19 import java.util.Collection;
20 import javax.xml.transform.Source;
21 import javax.xml.transform.stream.StreamSource;
22 import javax.xml.validation.Schema;
23 import javax.xml.validation.SchemaFactory;
24 import javax.xml.validation.Validator;
25 import javax.xml.XMLConstants;
26 import javax.xml.parsers.ParserConfigurationException;
27 import javax.xml.transform.TransformerException;
28 import javax.xml.xpath.XPathExpressionException;
29 import org.exmaralda.partitureditor.jexmaralda.JexmaraldaException;
30 import org.jdom.JDOMException;
31 import org.xml.sax.SAXException;
49 throws SAXException, JDOMException, IOException, JexmaraldaException, TransformerException, ParserConfigurationException, XPathExpressionException{
50 System.out.println(
"Checking COMA file against schema...");
51 URL COMA_XSD =
new URL(
"http://www.exmaralda.org/xml/comacorpus.xsd");
53 SchemaFactory schemaFactory =
54 SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
55 Schema schema = schemaFactory.newSchema(COMA_XSD);
56 Validator validator = schema.newValidator();
58 validator.setErrorHandler(eh);
59 validator.validate(xmlStream);
70 Class cl = Class.forName(
"de.uni_hamburg.corpora.ComaData");
72 }
catch (ClassNotFoundException ex) {
73 report.
addException(ex,
"unknown class not found error");
83 String description =
"This class validates the coma file with the respective XML schema. ";
88 public Report function(
Corpus c, Boolean fix)
throws SAXException, JDOMException, IOException, JexmaraldaException, TransformerException, ParserConfigurationException, XPathExpressionException {
91 stats =
function(cd, fix);
Collection< Class<?extends CorpusData > > getIsUsableFor()
static InputStream String2InputStream(String s)
void addException(Throwable e, String description)