phax / ph-schematron

Java Schematron library that supports XSLT and native application
Apache License 2.0
115 stars 36 forks source link

Should assertions with flag/role "CAUTION" be considered as INFO findings? #168

Closed costas80 closed 6 months ago

costas80 commented 6 months ago

A failed assertion with a flag or role of CAUTION is currently considered as a warning. This comes from the implementation in class DefaultSVRLErrorLevelDeterminator, and in particular method getDefaultErrorLevelFromString:

  public static IErrorLevel getDefaultErrorLevelFromString (@Nullable final String sFlag)
  {
    if (sFlag != null)
    {
      ...
      if (sFlag.equalsIgnoreCase ("warning") || sFlag.equalsIgnoreCase ("warn") || sFlag.equalsIgnoreCase ("caution"))
        return EErrorLevel.WARN;
      ...
    }

    return null;
  }

However, when referring to https://schematron.com/document/141.html there is a suggestion to treat "CAUTION" as "LSP information":

@role="CAUTION"  – It may not be wrong, but care is required. Or a system might be expected to process the document in a special way because of this.
LSP Information
ISQB S4 TRIVIAL

Is the current implementation of DefaultSVRLErrorLevelDeterminator incorrect in its handling of CAUTION assertions (i.e. should they be mapped instead to EErrorLevel.INFO?

I would debate that the current implementation is correct, but we have had certain of our users point out that it is not (we use the resulting error level to present findings as warnings or errors accordingly).

What is your opinion about this?

phax commented 6 months ago

Thanks for ponting that out. Also the reference to the intended error levels is very interesting. As the Schematron documentation may not be there forever, I am taking the liberty of copying the table over:

@role="FATAL"  – something so bad that processing or validation should or did stop.
    LSP Error
    ISQB S1 CRITICAL
@role="ERROR"  – something  wrong has occurred but processing may continue
    LSP Error
    ISQB S2 MAJOR
@role="WARN"  – something wrong has happened, but it does not necessarily require action
    LSP Warning
    ISQB S3 MINOR
@role="CAUTION"  – It may not be wrong, but care is required. Or a system might be expected to process the document in a special way because of this.
    LSP Information
    ISQB S4 TRIVIAL
@role="INFO"  – some information is being reported
    LSP Information
@role="HINT"  – some hint is being given to the user
    LSP Hint
@role="TRACE"  – some information on execution is being reported.
    LSP Information
@role="DEBUG"  – some information that is not intended for exposure in production.
    LSP Hint
phax commented 6 months ago

Will be part of the next 8.0.1 release. If it is okay for you, I won't build an immediate release...

costas80 commented 6 months ago

Thanks for the fast reaction @phax ! No problem to wait for 8.0.1. As you already expose the role value on the resulting messages we can already check it and "force" an information level.