checkin for alpha release attempt

This commit is contained in:
Jochen Stärk
2020-08-06 16:26:53 +02:00
parent a98e495947
commit fd947e04d5
5 changed files with 51 additions and 14 deletions

View File

@@ -25,20 +25,37 @@ public abstract class Validator {
}
//abstract method
/***
* prepare validation
* @param filename the filename of the xml file to be examined
* @throws IrrecoverableValidationError when any fatal errors arise, e.g. when the source file can not be found
*/
public abstract void setFilename(String filename) throws IrrecoverableValidationError;
/***
* perform the validation
* @throws IrrecoverableValidationError any fatal errors, e.g. when the source file can not be found
*/
public abstract void validate() throws IrrecoverableValidationError;
/**
* get validation result
* @return validation result as xml string
*/
public String getXMLResult() {
return context.getXMLResult();
}
/***
* validates a schema, which can only be needed in XML validation - and in pdf validation for additional data
* @param xmlRawData
* @param schemaPath
* @param xmlRawData the XML to be validated
* @param schemaPath the filename of the schema file
* @param section the error message type code
* @param part whether the error message occurs in the pdf or xml part
* @throws IrrecoverableValidationError when any fatal errors arise, e.g. when the source file can not be found
*/
protected void validateSchema(byte[] xmlRawData, String schemaPath,int section, EPart part) throws IrrecoverableValidationError {
protected void validateSchema(byte[] xmlRawData, String schemaPath, int section, EPart part) throws IrrecoverableValidationError {
URL schemaFile = ClassLoader.getSystemResource("schema/" + schemaPath);
Source xmlData = new StreamSource(new ByteArrayInputStream(xmlRawData));
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

View File

@@ -51,6 +51,11 @@ public class XMLValidator extends Validator {
super(ctx);
}
/***
* set source file
* @param name
* @throws IrrecoverableValidationError
*/
public void setFilename(String name) throws IrrecoverableValidationError { // from XML Filename
filename = name;
// file existence must have been checked before
@@ -69,10 +74,20 @@ public class XMLValidator extends Validator {
}
}
/***
* manually set the xml content
* @param xml the xml to be checked
*/
public void setStringContent(String xml) {
zfXML = xml;
}
/**
* whether uri1 has the same meaning like uri1 (it has, if it only differs in the fragment, i.e. uri1#1==uri1#2 )
* @param uri1
* @param uri2
* @return true if semantically identical
*/
public static boolean matchesURI(String uri1, String uri2) {
return (uri1.equals(uri2) || uri1.startsWith(uri2 + "#"));
}
@@ -85,13 +100,10 @@ public class XMLValidator extends Validator {
disableNotices = true;
}
/***
*
* @param xmlString
* @param overrideProfileCheck
* if set to true, all ZF2 files will be checked against EN16931
* schematron, since no other schematron is available
* @return
* perform validation
* @throws IrrecoverableValidationError if any fatal errors occur, e.g. source file can not be read
*/
@Override
public void validate() throws IrrecoverableValidationError {
@@ -315,6 +327,14 @@ public class XMLValidator extends Validator {
}
/***
* validate using a xslt file generated from a schematron in the build preparation of this software
* @param xml the xml to be checked
* @param xsltFilename the filename of the intermediate XSLT file
* @param section the error type code, if one arises
* @param severity how serious a error should be treated - may only be notice
* @throws IrrecoverableValidationError if anything happened that prevents further checks
*/
public void validateSchematron(String xml, String xsltFilename, int section, ESeverity severity) throws IrrecoverableValidationError {
ISchematronResource aResSCH = null;
aResSCH = SchematronResourceXSLT.fromClassPath(xsltFilename);