Xerces-C++: DOMNodeFilter Class Reference (original) (raw)

Filters are objects that know how to "filter out" nodes. More...

#include <[xercesc/dom/DOMNodeFilter.hpp](DOMNodeFilter%5F8hpp%5Fsource.html)>

Public Types
Public Constants
enum FilterAction { FILTER_ACCEPT = 1 , FILTER_REJECT = 2 , FILTER_SKIP = 3 }
Constants returned by acceptNode. More...
enum ShowTypeMasks { SHOW_ALL = 0x0000FFFF , SHOW_ELEMENT = 0x00000001 , SHOW_ATTRIBUTE = 0x00000002 , SHOW_TEXT = 0x00000004 , SHOW_CDATA_SECTION = 0x00000008 , SHOW_ENTITY_REFERENCE = 0x00000010 , SHOW_ENTITY = 0x00000020 , SHOW_PROCESSING_INSTRUCTION = 0x00000040 , SHOW_COMMENT = 0x00000080 , SHOW_DOCUMENT = 0x00000100 , SHOW_DOCUMENT_TYPE = 0x00000200 , SHOW_DOCUMENT_FRAGMENT = 0x00000400 , SHOW_NOTATION = 0x00000800 }
Constants for whatToShow. More...
typedef unsigned long ShowType
Public Member Functions
Destructor
virtual ~DOMNodeFilter ()
Destructor.
Functions introduced in DOM Level 2
virtual FilterAction acceptNode (const DOMNode *node) const =0
Test whether a specified node is visible in the logical view of a DOMTreeWalker or DOMNodeIterator.
Protected Member Functions
Hidden constructors

Filters are objects that know how to "filter out" nodes.

If a [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.") or [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") is given a [DOMNodeFilter](classDOMNodeFilter.html "Filters are objects that know how to "filter out" nodes."), it applies the filter before it returns the next node. If the filter says to accept the node, the traversal logic returns it; otherwise, traversal looks for the next node and pretends that the node that was rejected was not there.

The DOM does not provide any filters. [DOMNodeFilter](classDOMNodeFilter.html "Filters are objects that know how to "filter out" nodes.") is just an interface that users can implement to provide their own filters.

DOMNodeFilters do not need to know how to traverse from node to node, nor do they need to know anything about the data structure that is being traversed. This makes it very easy to write filters, since the only thing they have to know how to do is evaluate a single node. One filter may be used with a number of different kinds of traversals, encouraging code reuse.

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification.

Since

DOM Level 2

ShowType

typedef unsigned long DOMNodeFilter::ShowType

FilterAction

Constants returned by acceptNode.

FILTER_ACCEPT: Accept the node. Navigation methods defined for [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.") or [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") will return this node.

FILTER_REJECT: Reject the node. Navigation methods defined for [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.") or [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") will not return this node. For [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ..."), the children of this node will also be rejected. DOMNodeIterators treat this as a synonym for FILTER_SKIP.

FILTER_SKIP: Skip this single node. Navigation methods defined for [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.") or [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") will not return this node. For both [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.") and [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ..."), the children of this node will still be considered.

Since

DOM Level 2

Enumerator
FILTER_ACCEPT
FILTER_REJECT
FILTER_SKIP

ShowTypeMasks

Constants for whatToShow.

SHOW_ALL: Show all [DOMNode(s)](classDOMNode.html "The DOMNode interface is the primary datatype for the entire Document Object Model.").

SHOW_ELEMENT: Show [DOMElement](classDOMElement.html "By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...") nodes.

SHOW_ATTRIBUTE: Show DOMAttr nodes. This is meaningful only when creating an [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.") or [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") with an attribute node as its root; in this case, it means that the attribute node will appear in the first position of the iteration or traversal. Since attributes are never children of other nodes, they do not appear when traversing over the document tree.

SHOW_TEXT: Show [DOMText](classDOMText.html "The DOMText interface inherits from DOMCharacterData and represents the textual content (termed chara...") nodes.

SHOW_CDATA_SECTION: Show [DOMCDATASection](classDOMCDATASection.html "CDATA sections are used to escape blocks of text containing characters that would otherwise be regard...") nodes.

SHOW_ENTITY_REFERENCE: Show [DOMEntityReference](classDOMEntityReference.html "DOMEntityReference objects may be inserted into the structure model when an entity reference is in th...") nodes.

SHOW_ENTITY: Show [DOMEntity](classDOMEntity.html "This interface represents an entity, either parsed or unparsed, in an XML document.") nodes. This is meaningful only when creating an [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.") or [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") with an [DOMEntity](classDOMEntity.html "This interface represents an entity, either parsed or unparsed, in an XML document.") node as its root; in this case, it means that the [DOMEntity](classDOMEntity.html "This interface represents an entity, either parsed or unparsed, in an XML document.") node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree.

SHOW_PROCESSING_INSTRUCTION: Show [DOMProcessingInstruction](classDOMProcessingInstruction.html "The DOMProcessingInstruction interface represents a "processinginstruction", used in XML as a way to ...") nodes.

SHOW_COMMENT: Show [DOMComment](classDOMComment.html "This interface inherits from CharacterData and represents the content of a comment,...") nodes.

SHOW_DOCUMENT: Show [DOMDocument](classDOMDocument.html "The DOMDocument interface represents the entire XML document.") nodes.

SHOW_DOCUMENT_TYPE: Show [DOMDocumentType](classDOMDocumentType.html "Each DOMDocument has a doctype attribute whose value is either null or a DOMDocumentType object.") nodes.

SHOW_DOCUMENT_FRAGMENT: Show [DOMDocumentFragment](classDOMDocumentFragment.html "DOMDocumentFragment is a "lightweight" or "minimal" DOMDocument object.") nodes.

SHOW_NOTATION: Show [DOMNotation](classDOMNotation.html "This interface represents a notation declared in the DTD.") nodes. This is meaningful only when creating an [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.") or [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") with a [DOMNotation](classDOMNotation.html "This interface represents a notation declared in the DTD.") node as its root; in this case, it means that the [DOMNotation](classDOMNotation.html "This interface represents a notation declared in the DTD.") node will appear in the first position of the traversal. Since notations are not part of the document tree, they do not appear when traversing over the document tree.

Since

DOM Level 2

Enumerator
SHOW_ALL
SHOW_ELEMENT
SHOW_ATTRIBUTE
SHOW_TEXT
SHOW_CDATA_SECTION
SHOW_ENTITY_REFERENCE
SHOW_ENTITY
SHOW_PROCESSING_INSTRUCTION
SHOW_COMMENT
SHOW_DOCUMENT
SHOW_DOCUMENT_TYPE
SHOW_DOCUMENT_FRAGMENT
SHOW_NOTATION
DOMNodeFilter::DOMNodeFilter ( ) protected

~DOMNodeFilter()

virtual DOMNodeFilter::~DOMNodeFilter ( ) virtual

Destructor.

acceptNode()

virtual FilterAction DOMNodeFilter::acceptNode ( const DOMNode * node) const pure virtual

Test whether a specified node is visible in the logical view of a [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") or [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g.").

This function will be called by the implementation of [DOMTreeWalker](classDOMTreeWalker.html "DOMTreeWalker objects are used to navigate a document tree or subtree using the view of the document ...") and [DOMNodeIterator](classDOMNodeIterator.html "DOMNodeIterators are used to step through a set of nodes, e.g."); it is not normally called directly from user code. (Though you could do so if you wanted to use the same filter to guide your own application logic.)

Parameters

node The node to check to see if it passes the filter or not.

Returns

A constant to determine whether the node is accepted, rejected, or skipped, as defined above.

Since

DOM Level 2

Implemented in DOMLSSerializerFilter.


The documentation for this class was generated from the following file: