| 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.Configuration; |
| 11 | import net.sf.saxon.event.Receiver; |
| 12 | import net.sf.saxon.om.Sequence; |
| 13 | import net.sf.saxon.trans.XPathException; |
| 14 | import javax.xml.stream.XMLStreamWriter; |
| 15 | |
| 16 | /** |
| 17 | * This class <code>InvalidityReportGenerator</code> extends the standard error handler for errors found during validation |
| 18 | * of an instance document against a schema, used if user specifies -report option on validate. Its effect is to output |
| 19 | * the validation errors found into the filename specified in an XML format. |
| 20 | */ |
| 21 | |
| 22 | public class InvalidityReportGenerator extends StandardInvalidityHandler { |
| 23 | |
| 24 | public static final String REPORT_NS = "http://saxon.sf.net/ns/validation"; |
| 25 | |
| 26 | |
| 27 | public InvalidityReportGenerator(Configuration config) { |
| 28 | super(config); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Create a Report Invalidity Handler writing to a Receiver |
| 33 | * |
| 34 | * @param config the Saxon configuration |
| 35 | * @param receiver required to output the validation errors |
| 36 | */ |
| 37 | public InvalidityReportGenerator(Configuration config, Receiver receiver) throws XPathException { |
| 38 | super(config); |
| 39 | |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Set the receiver |
| 44 | * @param receiver required to output the validation errors |
| 45 | */ |
| 46 | public void setReceiver(Receiver receiver){ |
| 47 | //no action |
| 48 | } |
| 49 | |
| 50 | |
| 51 | |
| 52 | /** |
| 53 | * Set the XML document that is to be validated |
| 54 | * |
| 55 | * @param id of the source document |
| 56 | */ |
| 57 | public void setSystemId(String id) { |
| 58 | |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Set the XSD document used to validation process |
| 63 | * |
| 64 | * @param name of xsd file |
| 65 | */ |
| 66 | public void setSchemaName(String name) { |
| 67 | |
| 68 | } |
| 69 | |
| 70 | public int getErrorCount() { |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | public int getWarningCount() { |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | public void setXsdVersion(String version) { |
| 79 | |
| 80 | } |
| 81 | |
| 82 | public XMLStreamWriter getWriter() { |
| 83 | return null; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Receive notification of a validity error. |
| 88 | * |
| 89 | * @param failure Information about the nature of the invalidity |
| 90 | */ |
| 91 | @Override |
| 92 | public void reportInvalidity(Invalidity failure) throws XPathException { |
| 93 | |
| 94 | } |
| 95 | |
| 96 | |
| 97 | /** |
| 98 | * At the start of a validation episode, initialize the handler |
| 99 | * |
| 100 | * @param systemId optional; may be used to represent the destination of any report produced |
| 101 | * @throws XPathException if initialization of the invalidity handler fails for any reason |
| 102 | */ |
| 103 | public void startReporting(String systemId) throws XPathException { |
| 104 | // no action |
| 105 | } |
| 106 | |
| 107 | public Sequence<?> endReporting() throws XPathException { |
| 108 | return null; |
| 109 | |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Create metedata element which contains summary information in the output XML document |
| 114 | * |
| 115 | * @throws XPathException |
| 116 | */ |
| 117 | |
| 118 | public void createMetaData() throws XPathException { |
| 119 | // no action |
| 120 | } |
| 121 | |
| 122 | } |