Class SchematronTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.SourceTask
name.jurgenei.gradle.xml.AbstractXmlValidationTask
name.jurgenei.gradle.xml.SchematronTask
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, ValidationTaskSpec, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.api.tasks.util.PatternFilterable, org.gradle.util.Configurable<org.gradle.api.Task>

@DisableCachingByDefault(because="Schematron compilation and validation depends on external schema files") public abstract class SchematronTask extends AbstractXmlValidationTask
Validates XML files via Schematron by compiling .sch to XSLT and producing SVRL output.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Named

    org.gradle.api.Named.Namer
  • Field Summary

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a Schematron validation task.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:check-assembled-schema.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:compact-report.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:debug.
    abstract org.gradle.api.provider.Property<String>
    SchXslt transpiler parameter schxslt:default-from.
    abstract org.gradle.api.provider.Property<String>
    SchXslt transpiler parameter schxslt:default-severity.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:expand-text.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:fail-early.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:handle-dynamic-errors.
    abstract org.gradle.api.provider.Property<String>
    SchXslt transpiler parameter schxslt:location-function.
    abstract org.gradle.api.provider.Property<String>
    SchXslt transpiler parameter schxslt:phase.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:report-active-pattern.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:report-fired-rule.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:report-skipped-assertion.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:report-suppressed-rule.
    abstract org.gradle.api.file.RegularFileProperty
    Returns the Schematron rules file used for validation.
    abstract org.gradle.api.provider.Property<String>
    SchXslt transpiler parameter schxslt:severity-threshold.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:streamable.
    abstract org.gradle.api.file.RegularFileProperty
    Optional destination for a compiled Schematron stylesheet.
    abstract org.gradle.api.provider.Property<Boolean>
    SchXslt transpiler parameter schxslt:terminate-validation-on-error.
    abstract org.gradle.api.file.RegularFileProperty
    Returns an optional override for the bundled SchXslt transpiler stylesheet.
    void
    schema(Object path)
    Sets the Schematron schema file using Gradle file notation.
    void
    style(Object path)
    Sets the compiled Schematron stylesheet output location.
    void
    Sets a custom transpiler stylesheet.
    validate(File inputFile, Map<String,String> params)
    Validates a single input file and returns normalized findings.

    Methods inherited from class org.gradle.api.tasks.SourceTask

    exclude, exclude, exclude, exclude, getExcludes, getIncludes, getPatternSet, getPatternSetFactory, include, include, include, include, setExcludes, setIncludes, setSource, setSource, source

    Methods inherited from class org.gradle.api.internal.ConventionTask

    conventionMapping, conventionMapping, getConventionMapping

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Constructor Details

    • SchematronTask

      public SchematronTask()
      Creates a Schematron validation task.
  • Method Details

    • getSchema

      @InputFile @PathSensitive(RELATIVE) public abstract org.gradle.api.file.RegularFileProperty getSchema()
      Returns the Schematron rules file used for validation.
      Returns:
      Schematron schema file used for validation
    • getTranspilerStylesheet

      @Optional @InputFile @PathSensitive(RELATIVE) public abstract org.gradle.api.file.RegularFileProperty getTranspilerStylesheet()
      Returns an optional override for the bundled SchXslt transpiler stylesheet.
      Returns:
      optional transpiler stylesheet overriding bundled SchXslt transpiler
    • getStyle

      @Optional @OutputFile public abstract org.gradle.api.file.RegularFileProperty getStyle()
      Optional destination for a compiled Schematron stylesheet.

      When set, the task reuses this file and recompiles only when needed based on schema/transpiler timestamps and transpiler-parameter fingerprint changes.

      Returns:
      optional compiled stylesheet location
    • getDebug

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getDebug()
      SchXslt transpiler parameter schxslt:debug. Enable or disable debugging. When debugging is enable, the validation stylesheet is indented. Defaults to false.
      Returns:
      optional debug flag
    • getPhase

      @Optional @Input public abstract org.gradle.api.provider.Property<String> getPhase()
      SchXslt transpiler parameter schxslt:phase. Name of the validation phase. The value '#DEFAULT' selects the pattern in the sch:schema/@defaultPhase attribute or '#ALL' if this attribute is not present. The value '#ALL' selects all patterns. Defaults to '#DEFAULT'.
      Returns:
      optional validation phase
    • getExpandText

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getExpandText()
      SchXslt transpiler parameter schxslt:expand-text. When set to boolean true, the validation stylesheet globally enables text value templates and you may use them in assertion or diagnostic messages. Defaults to false.
      Returns:
      optional expand-text flag
    • getStreamable

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getStreamable()
      SchXslt transpiler parameter schxslt:streamable. Set to boolean true to create a streamable validation stylesheet. This does not check the streamability of XPath expressions in rules, assertions, variables etc. It merely declares the modes in the validation stylesheet to be streamable and removes the @location attribute from the SVRL output when no location function is given because the default fn:path() is not streamable. Defaults to false.
      Returns:
      optional streamable flag
    • getLocationFunction

      @Optional @Input public abstract org.gradle.api.provider.Property<String> getLocationFunction()
      SchXslt transpiler parameter schxslt:location-function. Name of a function f($context as node()) as xs:string that provides location information for the SVRL report. Defaults to fn:path() when not set.
      Returns:
      optional location function name
    • getFailEarly

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getFailEarly()
      SchXslt transpiler parameter schxslt:fail-early. When set to boolean true, the validation stylesheet stops as soon as it encounters the first failed assertion or successful report. Defaults to false.
      Returns:
      optional fail-early flag
    • getTerminateValidationOnError

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getTerminateValidationOnError()
      SchXslt transpiler parameter schxslt:terminate-validation-on-error. When set to boolean true, the validation stylesheet terminates the XSLT processor when it encounters a dynamic error. Defaults to true.
      Returns:
      optional terminate-on-error flag
    • getReportActivePattern

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getReportActivePattern()
      SchXslt transpiler parameter schxslt:report-active-pattern. When set to boolean true, the validation stylesheet reports active patterns and groups. Defaults to true.
      Returns:
      optional report-active-pattern flag
    • getReportFiredRule

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getReportFiredRule()
      SchXslt transpiler parameter schxslt:report-fired-rule. When set to boolean true, the validation stylesheet reports fired rules. Defaults to true.
      Returns:
      optional report-fired-rule flag
    • getReportSuppressedRule

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getReportSuppressedRule()
      SchXslt transpiler parameter schxslt:report-suppressed-rule. When set to boolean true, the validation stylesheet reports suppressed rules. Defaults to true.
      Returns:
      optional report-suppressed-rule flag
    • getReportSkippedAssertion

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getReportSkippedAssertion()
      SchXslt transpiler parameter schxslt:report-skipped-assertion. When set to boolean true, the validation stylesheet reports assertions that are skipped. Defaults to true.
      Returns:
      optional report-skipped-assertion flag
    • getCompactReport

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getCompactReport()
      SchXslt transpiler parameter schxslt:compact-report. When set to boolean true, the validation stylesheet only reports failed assertions, successful reports and errors. Defaults to false.
      Returns:
      optional compact-report flag
    • getSeverityThreshold

      @Optional @Input public abstract org.gradle.api.provider.Property<String> getSeverityThreshold()
      SchXslt transpiler parameter schxslt:severity-threshold. Assertions with a severity lesser than the threshold are not checked. One of 'info', 'warning', 'error', or 'fatal'. Defaults to 'info'.
      Returns:
      optional severity threshold
    • getDefaultSeverity

      @Optional @Input public abstract org.gradle.api.provider.Property<String> getDefaultSeverity()
      SchXslt transpiler parameter schxslt:default-severity. Severity of assertions without an @severity attribute. One of 'info', 'warning', 'error', or 'fatal'. Defaults to 'fatal'.
      Returns:
      optional default severity
    • getDefaultFrom

      @Optional @Input public abstract org.gradle.api.provider.Property<String> getDefaultFrom()
      SchXslt transpiler parameter schxslt:default-from. Default value of the expression that selects the subset of the document to be validate. Can be overwritten on a per-phase basis by the @from attribute. The default from expression also applies to the phase '#ALL'. Defaults to 'root()'.
      Returns:
      optional default from expression
    • getCheckAssembledSchema

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getCheckAssembledSchema()
      SchXslt transpiler parameter schxslt:check-assembled-schema. When set to boolean true, the transpiler performs some plausability checks after all external definitions are included. It terminates with an error if it finds errors in the assembled schema. Defaults to false.
      Returns:
      optional check-assembled-schema flag
    • getHandleDynamicErrors

      @Optional @Input public abstract org.gradle.api.provider.Property<Boolean> getHandleDynamicErrors()
      SchXslt transpiler parameter schxslt:handle-dynamic-errors. When set to boolean true, the validation stylesheet writes dynamic errors as a svrl:error element to the validation report and terminates with a schxslt:ValidationError error. When set to false, dynamic errors bubble up to the XSLT processor. Defaults to true.
      Returns:
      optional handle-dynamic-errors flag
    • schema

      public void schema(Object path)
      Sets the Schematron schema file using Gradle file notation.
      Parameters:
      path - file notation accepted by Project.file
    • transpilerStylesheet

      public void transpilerStylesheet(Object path)
      Sets a custom transpiler stylesheet.
      Parameters:
      path - file notation accepted by Project.file
    • style

      public void style(Object path)
      Sets the compiled Schematron stylesheet output location.
      Parameters:
      path - file notation accepted by Project.file
    • validate

      protected ValidationResult validate(File inputFile, Map<String,String> params) throws Exception
      Description copied from class: AbstractXmlValidationTask
      Validates a single input file and returns normalized findings.
      Specified by:
      validate in class AbstractXmlValidationTask
      Parameters:
      inputFile - file to validate
      params - task-level validation parameters
      Returns:
      normalized validation result
      Throws:
      Exception - when validation cannot be performed