/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id$ */ #if !defined(XERCESC_INCLUDE_GUARD_DOMLSPARSERFILTER_HPP) #define XERCESC_INCLUDE_GUARD_DOMLSPARSERFILTER_HPP /** * * DOMLSParserFilter.hpp: interface for the DOMLSParserFilter class. * * DOMLSParserFilter provide applications the ability to examine nodes * as they are being created during the parse process. * * DOMLSParserFilter lets the application decide what nodes should be * in the output DOM tree or not. * * @since DOM Level 3 */ #include XERCES_CPP_NAMESPACE_BEGIN class DOMElement; class DOMNode; class CDOM_EXPORT DOMLSParserFilter { protected: // ----------------------------------------------------------------------- // Hidden constructors // ----------------------------------------------------------------------- /** @name Hidden constructors */ //@{ DOMLSParserFilter() {}; //@} private: // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- /** @name Unimplemented constructors and operators */ //@{ DOMLSParserFilter(const DOMLSParserFilter &); DOMLSParserFilter & operator = (const DOMLSParserFilter &); //@} public: // ----------------------------------------------------------------------- // All constructors are hidden, just the destructor is available // ----------------------------------------------------------------------- /** @name Destructor */ //@{ /** * Destructor * */ virtual ~DOMLSParserFilter() {}; //@} // ----------------------------------------------------------------------- // Class Types // ----------------------------------------------------------------------- /** @name Public Contants */ //@{ /** * Constants returned by acceptNode. * *

FILTER_ACCEPT: * Accept the node.

* *

FILTER_REJECT: * Reject the node and its children.

* *

FILTER_SKIP: * Skip this single node. The children of this node will still be considered.

* *

FILTER_INTERRUPT: * Interrupt the normal processing of the document.

* * @since DOM Level 3 */ enum FilterAction {FILTER_ACCEPT = 1, FILTER_REJECT = 2, FILTER_SKIP = 3, FILTER_INTERRUPT = 4}; // ----------------------------------------------------------------------- // Virtual DOMLSParserFilter interface // ----------------------------------------------------------------------- /** @name Functions introduced in DOM Level 3 */ //@{ /** * This method will be called by the parser at the completion of the parsing of each node. * The node and all of its descendants will exist and be complete. The parent node will also exist, * although it may be incomplete, i.e. it may have additional children that have not yet been parsed. * Attribute nodes are never passed to this function. * 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. * * @param node The newly constructed element. At the time this method is called, the element is complete - * it has all of its children (and their children, recursively) and attributes, and is attached * as a child to its parent. * @return One of the FilterAction enum */ virtual FilterAction acceptNode(DOMNode* node) = 0; /** * The parser will call this method after each DOMElement start tag has been scanned, * but before the remainder of the DOMElement is processed. The intent is to allow the element, * including any children, to be efficiently skipped. Note that only element nodes are passed to the * startElement function. * The element node passed to startElement for filtering will include all of the attributes, but none * of the children nodes. The DOMElement may not yet be in place in the document being * constructed (it may not have a parent node.) * A startElement filter function may access or change the attributes for the DOMElement. * Changing namespace declarations will have no effect on namespace resolution by the parser. * * @param node The newly encountered element. At the time this method is called, the element is incomplete - * it will have its attributes, but no children. * @return One of the FilterAction enum */ virtual FilterAction startElement(DOMElement* node) = 0; /** * Tells the DOMLSParser what types of nodes to show to the method DOMLSParserFilter::acceptNode. * If a node is not shown to the filter using this attribute, it is automatically included in the DOM document being built. * See DOMNodeFilter for definition of the constants. The constants SHOW_ATTRIBUTE, SHOW_DOCUMENT, * SHOW_DOCUMENT_TYPE, SHOW_NOTATION, SHOW_ENTITY, and SHOW_DOCUMENT_FRAGMENT are meaningless here. * Those nodes will never be passed to DOMLSParserFilter::acceptNode. * * @return The constants of what types of nodes to show. * @since DOM Level 3 */ virtual DOMNodeFilter::ShowType getWhatToShow() const = 0; //@} }; XERCES_CPP_NAMESPACE_END #endif