Class PolicyChecker


  • public final class PolicyChecker
    extends Object
    The veraPDF policy checker which is simply an abstraction that makes applying XML schematron to veraPDF reports straightforward.
    Version:
    0.1 Created 12 Dec 2016:17:51:12
    Author:
    Carl Wilson carlwilson AT github
    • Field Detail

      • allowedExtensions

        public static final List<String> allowedExtensions
        A List of allowed extensions for the passed schmeatron rules. These can be:
        • .sch which is a raw, uncompiled schematron file which will be compiled to the appropriate XSL by the policy checker.
        • .xsl which is a pre-compiled schematron represented as an XSLT file.
        • .xslt the longer form of the .xsl extension, again a pre-compiled schematron file.
    • Method Detail

      • insertPolicyReport

        public static void insertPolicyReport​(File policyReport,
                                              File mrrReport,
                                              OutputStream mergedReport)
                                       throws VeraPDFException
        Adds a policy report to a veraPDF machine readable report instance, effectively a merge carried out by an XSLT transform.
        Parameters:
        policyReport - the XML policy report File to add to the machine readable report.
        mrrReport - the XML machine readable report File to add the policy report to
        mergedReport - and OutputStream destination for the merged report.
        Throws:
        VeraPDFException - when there's an error merging the reports.
      • applyPolicy

        public static void applyPolicy​(File policy,
                                       InputStream xmlReport,
                                       OutputStream policyReport)
                                throws VeraPDFException
        Apply a veraPDF policy expressed as schematron to a veraPDF report. Note that the schematron can be a "raw" schematron file
        Parameters:
        policy - a File that is either a raw schematron file (.sch extenstion) or pre-compiled schematron file (.xsl or .xslt extenstion), see allowedExtensions
        xmlReport - an InputStream for the veraPDF XML report to apply policy to
        policyReport - an OutputStream to which the ouptut policy file will be written
        Throws:
        VeraPDFException - when there's a problem applying the policy schematron rules.
      • isFilenameAllowedExtension

        public static boolean isFilenameAllowedExtension​(String filename)
        Check if a filename has an allowed policy file extension
        Parameters:
        filename - the filename to check
        Returns:
        true if the filename has a recognised policy extension
      • isAllowedExtension

        public static boolean isAllowedExtension​(String ext)
        Check if an extenstion is an allowed policy file extension
        Parameters:
        ext - the extension to check
        Returns:
        true if the extension is a recognised policy extension
      • applyPolicy

        public static void applyPolicy​(InputStream policy,
                                       InputStream xmlReport,
                                       OutputStream policyReport,
                                       boolean isXsl)
                                throws VeraPDFException
        Apply a veraPDF policy expressed as schematron to a veraPDF report. Note that the schematron can be a "raw" schematron file
        Parameters:
        policy - an InputStream for either raw schematron or pre-compiled schematron XSL.
        xmlReport - an InputStream for the veraPDF XML report to apply policy to
        policyReport - an OutputStream to which the ouptut policy file will be written
        isXsl - set true if the policy stream is a pre-compiled XSL policy document, false if it's a raw Schematron document.
        Throws:
        VeraPDFException - when there's a problem applying the policy schematron rules.