/**
* Performs all validation schema checks contained in the validation profile. If the validation has failed (some of the XMLs
* specified in the validation profile do not match their respective validation schemas) {@link SchemaValidationError} is thrown.
*
* @param sipPath path to the SIP
* @param validationProfileDoc document with the validation profile
* @param validationProfileId id of the validation profile
* @throws IOException if some of the XMLs address from the validation profile does not exist
* @throws XPathExpressionException if there is an error in the XPath expression
* @throws SAXException if the XSD schema is invalid
*/
private void performValidationSchemaChecks(String sipPath, Document validationProfileDoc, String validationProfileId) throws
XPathExpressionException, IOException, SAXException {
XPath xPath = XPathFactory.newInstance().newXPath();
NodeList nodes = (NodeList) xPath.compile("/profile/rule/validationSchemaCheck")
.evaluate(validationProfileDoc,
XPathConstants.NODESET);
for (int i = 0; i< nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
String filePath = element.getElementsByTagName("filePath").item(0).getTextContent();
String schema = element.getElementsByTagName("schema").item(0).getTextContent();
String absoluteFilePath = sipPath + filePath;
try {
ValidationChecker.validateWithXMLSchema(new FileInputStream(absoluteFilePath), new InputStream[] {
new ByteArrayInputStream(schema.getBytes(StandardCharsets.UTF_8.name()))});
} catch (GeneralException e) {
log.info("Validation of SIP with profile " + validationProfileId + " failed. File at \"" + filePath + "\" is not " +
"valid against its corresponding schema.");
throw new SchemaValidationError(filePath, schema, e.getMessage());
}
}
}
ValidationService.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:ARCLib
作者:
评论列表
文章目录