LSParserFilters provide applications the ability to examine nodes as they are being constructed while parsing. As each node is examined, it may be modified or removed, or the entire parse may be terminated early.
At the time any of the filter methods are called by the parser, the
owner Document and DOMImplementation objects exist and are accessible.
The document element is never passed to the
methods, i.e. it is not possible to filter out the document element.
Attr nodes are never passed to the
acceptNode method on the filter. The child nodes of an
EntityReference node are passed to the filter if the
entities" is set to
false. Note that, as described by the parameter "
entities", unexpanded entity reference nodes are never discarded and are always
passed to the filter.
All validity checking while parsing a document occurs on the source document as it appears on the input stream, not on the DOM document as it is built in memory. With filters, the document in memory may be a subset of the document on the stream, and its validity may have been affected by the filtering.
All default attributes must be present on elements when the elements are passed to the filter methods. All other default content must be passed to the filter methods.
DOM applications must not raise exceptions in a filter. The effect of throwing exceptions from a filter is DOM implementation dependent.
See also the Document Object Model (DOM) Level 3 Load and Save Specification.
|public static final short||FILTER_ACCEPT||Accept the node.|
|public static final short||FILTER_REJECT||Reject the node and its children.|
|public static final short||FILTER_SKIP||Skip this single node. The children of this node will still be considered.|
|public static final short||FILTER_INTERRUPT||Interrupt the normal processing of the document.|
|Method from org.w3c.dom.ls.LSParserFilter Summary:|
|acceptNode, getWhatToShow, startElement|
|Method from org.w3c.dom.ls.LSParserFilter Detail:|
public short acceptNode(Node nodeArg)
From within this method, the new node may be freely modified - children may be added or removed, text nodes modified, etc. The state of the rest of the document outside this node is not defined, and the affect of any attempt to navigate to, or to modify any other part of the document is undefined.
For validating parsers, the checks are made on the original document, before any modification by the filter. No validity checks are made on any document modifications made by the filter.
If this new node is rejected, the parser might reuse the new node and any of its descendants.
public int getWhatToShow()
The constants used here are defined in [DOM Level 2 Traversal and Range] .
public short startElement(Element elementArg)
The element node passed to
For efficiency, the Element node passed to the filter may not be the same one as is actually placed in the tree if the node is accepted. And the actual node (node object identity) may be reused during the process of reading in and filtering a document.