-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Milestone
Description
Hi!
I am having trouble integrating the ODF Validator through Maven in my Java project.
I can't find the proper import option as part of org.odftoolkit.
I also had to add <type>pom</type> to the pom.xml dependency configuration. See issue: #212
This is the code I am using, which in theory should work (I think):
import org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument;
import org.odftoolkit.odfvalidator.ODFValidator;
import org.odftoolkit.odfvalidator.result.ValidationResult;
public class validate {
// Validate OpenDocument Spreadsheets using ODF Validator
public boolean Validate_ODFValidator(String filepath) throws Exception {
boolean valid = false;
OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.loadDocument(filepath);
ODFValidator validator = new ODFValidator();
ValidationResult result = validator.validate(spreadsheet);
// Inform user and return boolean
if (result.hasErrors()) {
System.out.println("VALIDATE: The spreadsheet file is invalid.");
System.out.println("VALIDATE: " + result.toString());
} else {
valid = true;
System.out.println("VALIDATE: The spreadsheet file is valid.");
}
return valid;
}
}
Can you help me?
Reactions are currently unavailable