use of org.apache.xmlbeans.XmlError in project knime-core by knime.
the class NodeDescription28Proxy method validate.
/**
* Validate against the XML Schema. If violations are found they are reported via the logger as coding problems.
*
* @return <code>true</code> if the document is valid, <code>false</code> otherwise
*/
protected final boolean validate() {
// this method has default visibility so that we can use it in testcases
XmlOptions options = new XmlOptions(OPTIONS);
List<XmlError> errors = new ArrayList<XmlError>();
options.setErrorListener(errors);
boolean valid = m_document.validate(options);
if (!valid) {
logger.coding("Node description of '" + m_document.getKnimeNode().getName() + "' does not conform to the Schema. Violations follow.");
for (XmlError err : errors) {
logger.coding(err.toString());
}
}
return valid;
}
use of org.apache.xmlbeans.XmlError in project knime-core by knime.
the class PMMLValidator method validatePMML.
/**
* Validates a document against the schema and returns the number of
* errors found.
*
* @param pmmlDocument the PMMML document
* @return the error message or an em
*/
public static Map<String, String> validatePMML(final PMMLDocument pmmlDocument) {
XmlOptions validateOptions = new XmlOptions();
List<XmlError> errorList = new ArrayList<XmlError>();
validateOptions.setErrorListener(errorList);
pmmlDocument.validate(validateOptions);
Map<String, String> errorMessages = new TreeMap<String, String>();
for (XmlError error : errorList) {
String location = error.getCursorLocation().xmlText();
if (location.length() > 50) {
location = location.substring(0, 50) + "[...]";
}
String errorMessage = error.getMessage().replace(PMML_NAMESPACE_URI, "");
LOGGER.error(location + ": " + errorMessage);
errorMessages.put(location, errorMessage);
}
return errorMessages;
}
Aggregations