| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.lib; |
| 9 | |
| 10 | import net.sf.saxon.om.Sequence; |
| 11 | import net.sf.saxon.trans.XPathException; |
| 12 | |
| 13 | /** |
| 14 | * Interface for reporting validation errors found during validation of an instance document |
| 15 | * against a schema. |
| 16 | */ |
| 17 | public interface InvalidityHandler { |
| 18 | |
| 19 | /** |
| 20 | * At the start of a validation episode, initialize the handler |
| 21 | * @param systemId optional; may be used to represent the destination of any report produced |
| 22 | * @throws XPathException if initialization of the invalidity handler fails for any reason |
| 23 | */ |
| 24 | |
| 25 | void startReporting(String systemId) throws XPathException; |
| 26 | |
| 27 | /** |
| 28 | * Report a validation error found during validation of an instance document |
| 29 | * against a schema |
| 30 | * @param failure details of the validation error |
| 31 | * @throws XPathException - if the validation error cannot be reported. |
| 32 | * This is fatal and will cause the validation run to be abandoned |
| 33 | */ |
| 34 | |
| 35 | void reportInvalidity(Invalidity failure) throws XPathException; |
| 36 | |
| 37 | /** |
| 38 | * At the end of a validation episode, do any closedown actions, and optionally return |
| 39 | * information collected in the course of validation (for example a list of error messages). |
| 40 | * @return a value to be associated with a validation exception. May be the empty sequence. |
| 41 | * In the case of the InvalidityReportGenerator, this returns the XML document |
| 42 | * containing the validation report. This will be the value returned as the value of |
| 43 | * the variable $err:value during try/catch processing |
| 44 | * @throws XPathException if an error occurs creating any validation report |
| 45 | */ |
| 46 | |
| 47 | Sequence<?> endReporting() throws XPathException; |
| 48 | } |
| 49 | |
| 50 |