| 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.event; |
| 9 | |
| 10 | import net.sf.saxon.expr.parser.Location; |
| 11 | import net.sf.saxon.om.Item; |
| 12 | import net.sf.saxon.om.NamespaceBindingSet; |
| 13 | import net.sf.saxon.om.NodeName; |
| 14 | import net.sf.saxon.type.SchemaType; |
| 15 | import net.sf.saxon.type.SimpleType; |
| 16 | |
| 17 | /** |
| 18 | * A Sink is an Receiver that discards all information passed to it |
| 19 | */ |
| 20 | |
| 21 | public class Sink extends SequenceReceiver { |
| 22 | |
| 23 | public Sink(PipelineConfiguration pipe) { |
| 24 | super(pipe); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Start of event stream |
| 29 | */ |
| 30 | |
| 31 | public void open() { |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * End of event stream |
| 36 | */ |
| 37 | |
| 38 | public void close() { |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Start of a document node. |
| 43 | */ |
| 44 | |
| 45 | public void startDocument(int properties) { |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Notify the end of a document node |
| 50 | */ |
| 51 | |
| 52 | public void endDocument() { |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Notify the start of an element |
| 57 | * @param nameCode integer code identifying the name of the element within the name pool. |
| 58 | * @param typeCode integer code identifying the element's type within the name pool. |
| 59 | * @param location |
| 60 | * @param properties for future use. Should be set to zero. |
| 61 | */ |
| 62 | |
| 63 | public void startElement(NodeName nameCode, SchemaType typeCode, Location location, int properties) { |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Notify a namespace. Namespaces are notified <b>after</b> the startElement event, and before |
| 68 | * any children for the element. The namespaces that are reported are only required |
| 69 | * to include those that are different from the parent element; however, duplicates may be reported. |
| 70 | * A namespace must not conflict with any namespaces already used for element or attribute names. |
| 71 | * |
| 72 | * @param namespaceBindings the prefix/uri pair representing the namespace binding to be written |
| 73 | * @throws java.lang.IllegalStateException: |
| 74 | * attempt to output a namespace when there is no open element |
| 75 | * start tag |
| 76 | */ |
| 77 | |
| 78 | public void namespace(NamespaceBindingSet namespaceBindings, int properties) { |
| 79 | |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Notify an attribute. Attributes are notified after the startElement event, and before any |
| 84 | * children. Namespaces and attributes may be intermingled. |
| 85 | * |
| 86 | * @param nameCode The name of the attribute |
| 87 | * @param typeCode The type of the attribute |
| 88 | * @param locationId the location of the node in the source, or of the instruction that created it |
| 89 | * @param properties Bit significant value. The following bits are defined: |
| 90 | * <dl> |
| 91 | * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> |
| 92 | * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> |
| 93 | * </dl> |
| 94 | * @throws java.lang.IllegalStateException: attempt to output an attribute when there is no open element |
| 95 | * start tag |
| 96 | */ |
| 97 | |
| 98 | public void attribute(NodeName nameCode, SimpleType typeCode, CharSequence value, Location locationId, int properties) { |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Notify the start of the content, that is, the completion of all attributes and namespaces. |
| 103 | * Note that the initial receiver of output from XSLT instructions will not receive this event, |
| 104 | * it has to detect it itself. Note that this event is reported for every element even if it has |
| 105 | * no attributes, no namespaces, and no content. |
| 106 | */ |
| 107 | |
| 108 | |
| 109 | public void startContent() { |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * End of element |
| 114 | */ |
| 115 | |
| 116 | public void endElement() { |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Character data |
| 121 | */ |
| 122 | |
| 123 | public void characters(CharSequence chars, Location locationId, int properties) { |
| 124 | } |
| 125 | |
| 126 | |
| 127 | /** |
| 128 | * Processing Instruction |
| 129 | */ |
| 130 | |
| 131 | public void processingInstruction(String target, CharSequence data, Location locationId, int properties) { |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Output a comment |
| 136 | */ |
| 137 | |
| 138 | public void comment(CharSequence chars, Location locationId, int properties) { |
| 139 | } |
| 140 | |
| 141 | |
| 142 | /** |
| 143 | * Append an arbitrary item (node or atomic value) to the output |
| 144 | * |
| 145 | * @param item the item to be appended |
| 146 | * @param locationId the location of the calling instruction, for diagnostics |
| 147 | * @param copyNamespaces if the item is an element node, this indicates whether its namespaces |
| 148 | * need to be copied. Values are {@link ReceiverOptions#ALL_NAMESPACES}, |
| 149 | * {@link ReceiverOptions#LOCAL_NAMESPACES}; the default (0) means |
| 150 | * no namespaces |
| 151 | */ |
| 152 | |
| 153 | public void append(Item item, Location locationId, int copyNamespaces) { |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Set the URI for an unparsed entity in the document. |
| 158 | */ |
| 159 | |
| 160 | public void setUnparsedEntity(String name, String uri, String publicId) { |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations |
| 165 | * supplied on element and attribute events |
| 166 | * |
| 167 | * @return true if the Receiver makes any use of this information. If false, the caller |
| 168 | * may supply untyped nodes instead of supplying the type annotation |
| 169 | */ |
| 170 | |
| 171 | public boolean usesTypeAnnotations() { |
| 172 | return false; |
| 173 | } |
| 174 | } |
| 175 |