39 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 40 */ 41 42 package org.w3c.dom.ls; 43 44 import org.w3c.dom.Node; 45 import org.w3c.dom.Element; 46 47 /** 48 * <code>LSParserFilter</code>s provide applications the ability to examine 49 * nodes as they are being constructed while parsing. As each node is 50 * examined, it may be modified or removed, or the entire parse may be 51 * terminated early. 52 * <p> At the time any of the filter methods are called by the parser, the 53 * owner Document and DOMImplementation objects exist and are accessible. 54 * The document element is never passed to the <code>LSParserFilter</code> 55 * methods, i.e. it is not possible to filter out the document element. 56 * <code>Document</code>, <code>DocumentType</code>, <code>Notation</code>, 57 * <code>Entity</code>, and <code>Attr</code> nodes are never passed to the 58 * <code>acceptNode</code> method on the filter. The child nodes of an 59 * <code>EntityReference</code> node are passed to the filter if the 60 * parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-entities'> 61 * entities</a>" is set to <code>false</code>. Note that, as described by the parameter "<a href='http://www.w3.org/TR/DOM-Level-3-Core/core.html#parameter-entities'> 62 * entities</a>", unexpanded entity reference nodes are never discarded and are always 63 * passed to the filter. 64 * <p> All validity checking while parsing a document occurs on the source 65 * document as it appears on the input stream, not on the DOM document as it 66 * is built in memory. With filters, the document in memory may be a subset 67 * of the document on the stream, and its validity may have been affected by 68 * the filtering. 69 * <p> All default attributes must be present on elements when the elements 70 * are passed to the filter methods. All other default content must be 71 * passed to the filter methods. 72 * <p> DOM applications must not raise exceptions in a filter. The effect of 73 * throwing exceptions from a filter is DOM implementation dependent. 74 * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407'>Document Object Model (DOM) Level 3 Load 75 and Save Specification</a>. 76 * 77 * @since 1.5 78 */ 79 public interface LSParserFilter { 80 // Constants returned by startElement and acceptNode 81 /** 82 * Accept the node. 83 */ 84 public static final short FILTER_ACCEPT = 1; 85 /** 86 * Reject the node and its children. 87 */ 88 public static final short FILTER_REJECT = 2; 89 /** 90 * Skip this single node. The children of this node will still be 91 * considered. 92 */ 93 public static final short FILTER_SKIP = 3; 94 /** 95 * Interrupt the normal processing of the document. 178 * <code>FILTER_INTERRUPT</code> if the filter wants to stop the 179 * processing of the document. Interrupting the processing of the 180 * document does no longer guarantee that the resulting DOM tree is 181 * XML well-formed. The <code>Node</code> is accepted and will be the 182 * last completely parsed node. 183 * </li> 184 * </ul> 185 */ 186 public short acceptNode(Node nodeArg); 187 188 /** 189 * Tells the <code>LSParser</code> what types of nodes to show to the 190 * method <code>LSParserFilter.acceptNode</code>. If a node is not shown 191 * to the filter using this attribute, it is automatically included in 192 * the DOM document being built. See <code>NodeFilter</code> for 193 * definition of the constants. The constants <code>SHOW_ATTRIBUTE</code> 194 * , <code>SHOW_DOCUMENT</code>, <code>SHOW_DOCUMENT_TYPE</code>, 195 * <code>SHOW_NOTATION</code>, <code>SHOW_ENTITY</code>, and 196 * <code>SHOW_DOCUMENT_FRAGMENT</code> are meaningless here. Those nodes 197 * will never be passed to <code>LSParserFilter.acceptNode</code>. 198 * <br> The constants used here are defined in [<a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>DOM Level 2 Traversal and Range</a>] 199 * . 200 */ 201 public int getWhatToShow(); 202 203 } | 39 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 40 */ 41 42 package org.w3c.dom.ls; 43 44 import org.w3c.dom.Node; 45 import org.w3c.dom.Element; 46 47 /** 48 * <code>LSParserFilter</code>s provide applications the ability to examine 49 * nodes as they are being constructed while parsing. As each node is 50 * examined, it may be modified or removed, or the entire parse may be 51 * terminated early. 52 * <p> At the time any of the filter methods are called by the parser, the 53 * owner Document and DOMImplementation objects exist and are accessible. 54 * The document element is never passed to the <code>LSParserFilter</code> 55 * methods, i.e. it is not possible to filter out the document element. 56 * <code>Document</code>, <code>DocumentType</code>, <code>Notation</code>, 57 * <code>Entity</code>, and <code>Attr</code> nodes are never passed to the 58 * <code>acceptNode</code> method on the filter. The child nodes of an 59 * <code>EntityReference</code> node are passed to the filter if the parameter 60 * "<a href='https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#parameter-entities'>entities</a>" 61 * is set to <code>false</code>. Note that, as described by the parameter 62 * "<a href='https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#parameter-entities'>entities</a>", 63 * unexpanded entity reference nodes are never discarded and are always 64 * passed to the filter. 65 * <p> All validity checking while parsing a document occurs on the source 66 * document as it appears on the input stream, not on the DOM document as it 67 * is built in memory. With filters, the document in memory may be a subset 68 * of the document on the stream, and its validity may have been affected by 69 * the filtering. 70 * <p> All default attributes must be present on elements when the elements 71 * are passed to the filter methods. All other default content must be 72 * passed to the filter methods. 73 * <p> DOM applications must not raise exceptions in a filter. The effect of 74 * throwing exceptions from a filter is DOM implementation dependent. 75 * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407'> 76 Document Object Model (DOM) Level 3 Load and Save Specification</a>. 77 * 78 * @since 1.5 79 */ 80 public interface LSParserFilter { 81 // Constants returned by startElement and acceptNode 82 /** 83 * Accept the node. 84 */ 85 public static final short FILTER_ACCEPT = 1; 86 /** 87 * Reject the node and its children. 88 */ 89 public static final short FILTER_REJECT = 2; 90 /** 91 * Skip this single node. The children of this node will still be 92 * considered. 93 */ 94 public static final short FILTER_SKIP = 3; 95 /** 96 * Interrupt the normal processing of the document. 179 * <code>FILTER_INTERRUPT</code> if the filter wants to stop the 180 * processing of the document. Interrupting the processing of the 181 * document does no longer guarantee that the resulting DOM tree is 182 * XML well-formed. The <code>Node</code> is accepted and will be the 183 * last completely parsed node. 184 * </li> 185 * </ul> 186 */ 187 public short acceptNode(Node nodeArg); 188 189 /** 190 * Tells the <code>LSParser</code> what types of nodes to show to the 191 * method <code>LSParserFilter.acceptNode</code>. If a node is not shown 192 * to the filter using this attribute, it is automatically included in 193 * the DOM document being built. See <code>NodeFilter</code> for 194 * definition of the constants. The constants <code>SHOW_ATTRIBUTE</code> 195 * , <code>SHOW_DOCUMENT</code>, <code>SHOW_DOCUMENT_TYPE</code>, 196 * <code>SHOW_NOTATION</code>, <code>SHOW_ENTITY</code>, and 197 * <code>SHOW_DOCUMENT_FRAGMENT</code> are meaningless here. Those nodes 198 * will never be passed to <code>LSParserFilter.acceptNode</code>. 199 * <br> The constants used here are defined in 200 * [<a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>DOM Level 2 Traversal and Range</a>]. 201 */ 202 public int getWhatToShow(); 203 204 } |