Skip to content

Integrate ODF Validator using Maven #215

Description

@Asbjoedt

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions