| 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.AbsolutePath; |
| 11 | |
| 12 | import javax.xml.transform.SourceLocator; |
| 13 | |
| 14 | /** |
| 15 | * An Invalidity is a validation error, that is, a failure of the instance document |
| 16 | * to conform to the schema being used for validation. |
| 17 | */ |
| 18 | public interface Invalidity extends SourceLocator { |
| 19 | |
| 20 | /** |
| 21 | * Get the part number of the XSD schema specification containing the constraint that |
| 22 | * has been violated |
| 23 | * @return 1 (XSD part 1, structures) or 2 (XSD part 2, data types) |
| 24 | */ |
| 25 | |
| 26 | int getSchemaPart(); |
| 27 | |
| 28 | /** |
| 29 | * Get the name of the constraint that has been violated |
| 30 | * @return the name of the constraint as defined in the XSD specification, for example "cvc-datatype-valid" |
| 31 | */ |
| 32 | |
| 33 | String getConstraintName(); |
| 34 | |
| 35 | /** |
| 36 | * Get the clause number of the rule that has been violated |
| 37 | * @return the clause number as a string, for example "3.4.1" |
| 38 | */ |
| 39 | |
| 40 | String getConstraintClauseNumber(); |
| 41 | |
| 42 | /** |
| 43 | * Get the constraint name and clause in the format defined in XML Schema Part 1 Appendix C (Outcome Tabulations). |
| 44 | * This mandates the format validation-rule-name.clause-number |
| 45 | * |
| 46 | * @return the constraint reference, for example "cos-ct-extends.1.2"; or null if the reference |
| 47 | * is not known. |
| 48 | */ |
| 49 | String getConstraintReference(); |
| 50 | |
| 51 | /** |
| 52 | * Get a hierarchic path giving the logical position in the instance document where the |
| 53 | * validation error was found |
| 54 | * @return a path to the location in the document |
| 55 | */ |
| 56 | |
| 57 | AbsolutePath getPath(); |
| 58 | |
| 59 | /** |
| 60 | * Get a hierarchic path giving the logical position in the instance document where the |
| 61 | * validation error was found |
| 62 | * @return a path to the location in the document |
| 63 | */ |
| 64 | |
| 65 | AbsolutePath getContextPath(); |
| 66 | |
| 67 | /** |
| 68 | * Get the text of a message explaining what is wrong |
| 69 | * @return a human-readable message explaining the validity error |
| 70 | */ |
| 71 | |
| 72 | String getMessage(); |
| 73 | |
| 74 | /** |
| 75 | * Get the error code associated with the validity error. This is relevant only when validation |
| 76 | * is run from within XSLT or XQuery, which define different error codes for validition errors |
| 77 | * @return the error code associated with the error, if any. The error is returned as a simple |
| 78 | * string if it is in the standard error namespace, or as an EQName (that is Q{uri}local) otherwise. |
| 79 | */ |
| 80 | |
| 81 | String getErrorCode(); |
| 82 | } |
| 83 |