Class PSPreprocessor

java.lang.Object
com.helger.schematron.pure.preprocess.PSPreprocessor

@NotThreadSafe public class PSPreprocessor extends Object
This is the pre-processor class for pure Schematron. It converts an existing schema to the minimal syntax (by default) but allows for a certain degree of customization by keeping certain elements in the resulting schema. The actual query binding is used, so that report test expressions can be converted to assertions, and to replace the content of <param> elements into actual values.
Author:
Philip Helger
  • Field Details

    • DEFAULT_KEEP_TITLES

      public static final boolean DEFAULT_KEEP_TITLES
      See Also:
    • DEFAULT_KEEP_DIAGNOSTICS

      public static final boolean DEFAULT_KEEP_DIAGNOSTICS
      See Also:
    • DEFAULT_KEEP_REPORTS

      public static final boolean DEFAULT_KEEP_REPORTS
      See Also:
    • DEFAULT_KEEP_EMPTY_PATTERNS

      public static final boolean DEFAULT_KEEP_EMPTY_PATTERNS
      See Also:
    • DEFAULT_KEEP_EMPTY_SCHEMA

      public static final boolean DEFAULT_KEEP_EMPTY_SCHEMA
      See Also:
  • Constructor Details

  • Method Details

    • getQueryBinding

      @Nonnull public IPSQueryBinding getQueryBinding()
      Returns:
      The query binding to be used. Never null!
    • isKeepTitles

      public boolean isKeepTitles()
      Returns:
      true if <title>-elements should be kept. Default is false.
    • setKeepTitles

      @Nonnull public PSPreprocessor setKeepTitles(boolean bKeepTitles)
      Should <title>-elements be kept?
      Parameters:
      bKeepTitles - true to keep titles, false otherwise.
      Returns:
      this for chaining
    • isKeepDiagnostics

      public boolean isKeepDiagnostics()
      Returns:
      true if <diagnostics>-elements should be kept. Default is false.
    • setKeepDiagnostics

      @Nonnull public PSPreprocessor setKeepDiagnostics(boolean bKeepDiagnostics)
      Should <diagnostics>-elements be kept?
      Parameters:
      bKeepDiagnostics - true to keep diagnostics, false otherwise.
      Returns:
      this for chaining
    • isKeepReports

      public boolean isKeepReports()
      Returns:
      true if <report>-elements should be kept, false if they should be converted to <assert>-elements. Default is false.
    • setKeepReports

      @Nonnull public PSPreprocessor setKeepReports(boolean bKeepReports)
      Should <report>-elements be kept or should they be converted to <assert>-elements?
      Parameters:
      bKeepReports - true to keep <report>-elements, false to change them to <assert>-elements
      Returns:
      this for chaining
    • isKeepEmptyPatterns

      public boolean isKeepEmptyPatterns()
      Returns:
      true if <pattern>-elements without a rule should be kept. Default is true.
    • setKeepEmptyPatterns

      @Nonnull public PSPreprocessor setKeepEmptyPatterns(boolean bKeepEmptyPatterns)
      Should <pattern>-elements without a single rule be kept or deleted?
      Parameters:
      bKeepEmptyPatterns - true to keep <pattern>-elements without a rule, false to delete them
      Returns:
      this for chaining
    • isKeepEmptySchema

      public boolean isKeepEmptySchema()
      Returns:
      true if <schema>-elements without a pattern should be kept. Default is true.
    • setKeepEmptySchema

      @Nonnull public PSPreprocessor setKeepEmptySchema(boolean bKeepEmptySchema)
      Should schema objects without a pattern be kept? It makes only sense to set it to false if setKeepEmptyPatterns(boolean) is also set to false, because otherwise patterns without rules are kept.
      Parameters:
      bKeepEmptySchema - true to keep them, false to discard them.
      Returns:
      this
    • getAsMinimalSchema

      @Nullable public PSSchema getAsMinimalSchema(@Nonnull PSSchema aSchema) throws SchematronPreprocessException
      Convert the passed schema to a minimal schema.
      Parameters:
      aSchema - The schema to be made minimal. May not be null
      Returns:
      The original schema object, if it is already minimal - a minimal copy otherwise! May be null if the original schema is not yet minimal and isKeepEmptySchema() is set to false.
      Throws:
      SchematronPreprocessException - In case a preprocessing error occurs
    • getAsPreprocessedSchema

      @Nullable public PSSchema getAsPreprocessedSchema(@Nonnull PSSchema aSchema) throws SchematronPreprocessException
      Convert the passed schema to a pre-processed schema.
      Parameters:
      aSchema - The schema to pre-process. May not be null
      Returns:
      The original schema object, if it is already pre-processed - a pre-processed copy otherwise! May be null if the original schema is not yet pre-processed and isKeepEmptySchema() is set to false.
      Throws:
      SchematronPreprocessException - In case a preprocessing error occurs
    • getForcedPreprocessedSchema

      @Nullable public PSSchema getForcedPreprocessedSchema(@Nonnull PSSchema aSchema) throws SchematronPreprocessException
      Convert the passed schema to a pre-processed schema independent if it is already minimal or not.
      Parameters:
      aSchema - The schema to be made minimal. May not be null
      Returns:
      A minimal copy of the schema. May be null if the original schema is not yet minimal and isKeepEmptySchema() is set to false.
      Throws:
      SchematronPreprocessException - In case a preprocessing error occurs
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createPreprocessorWithoutInformationLoss

      @Nonnull public static PSPreprocessor createPreprocessorWithoutInformationLoss(@Nonnull IPSQueryBinding aQueryBinding)