00001 /* 00002 * Copyright 2002-2005 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /* 00018 * XSEC 00019 * 00020 * TXFMXPath := Class that performs XPath transforms 00021 * 00022 * $Id: TXFMXPathFilter.hpp 394035 2006-04-14 06:53:07Z blautenb $ 00023 * 00024 */ 00025 00026 #if !defined (TXFMXPATHFILTER_HEADER) 00027 #define XFMXPATHFILTER_HEADER 00028 00029 #include <xsec/transformers/TXFMBase.hpp> 00030 #include <xsec/utils/XSECXPathNodeList.hpp> 00031 #include <xsec/dsig/DSIGTransformXPathFilter.hpp> 00032 #include <xsec/dsig/DSIGConstants.hpp> 00033 00034 // Xerces 00035 00036 XSEC_DECLARE_XERCES_CLASS(DOMNode); 00037 XSEC_DECLARE_XERCES_CLASS(DOMNamedNodeMap); 00038 00039 class TXFMXPathFilterExpr; 00040 class XSECSafeBufferFormatter; 00041 00042 struct filterSetHolder { 00043 00044 XSECXPathNodeList * lst; 00045 xpathFilterType type; 00046 XERCES_CPP_NAMESPACE_QUALIFIER DOMNode 00047 * ancestorInScope; 00048 00049 }; 00050 00051 00052 #ifndef XSEC_NO_XPATH 00053 00060 class DSIG_EXPORT TXFMXPathFilter : public TXFMBase { 00061 00062 public: 00063 00064 TXFMXPathFilter(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc); 00065 ~TXFMXPathFilter(); 00066 00067 // Methods to set the inputs 00068 00069 void setInput(TXFMBase *newInput); 00070 00071 // Methods to get tranform output type and input requirement 00072 00073 virtual TXFMBase::ioType getInputType(void); 00074 virtual TXFMBase::ioType getOutputType(void); 00075 virtual TXFMBase::nodeType getNodeType(void); 00076 00077 // XPathFilter unique 00078 00079 void evaluateExprs(DSIGTransformXPathFilter::exprVectorType * exprs); 00080 XSECXPathNodeList * evaluateSingleExpr(DSIGXPathFilterExpr *expr); 00081 00082 // Methods to get output data 00083 00084 virtual unsigned int readBytes(XMLByte * const toFill, const unsigned int maxToFill); 00085 virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *getDocument(); 00086 virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *getFragmentNode(); 00087 virtual const XMLCh * getFragmentId(); 00088 virtual XSECXPathNodeList & getXPathNodeList(); 00089 00090 private: 00091 00092 typedef std::vector<filterSetHolder *> lstsVectorType; 00093 TXFMXPathFilter(); 00094 void walkDocument(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * n); 00095 bool checkNodeInScope(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * n); 00096 bool checkNodeInInput(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * n, 00097 XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * attParent); 00098 00099 00100 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument 00101 * document; 00102 XSECXPathNodeList m_xpathFilterMap; 00103 lstsVectorType m_lsts; 00104 00105 XSECSafeBufferFormatter * mp_formatter; 00106 00107 /* Used to hold details during tree-walk */ 00108 XERCES_CPP_NAMESPACE_QUALIFIER DOMNode 00109 * mp_fragment; 00110 XSECXPathNodeList * mp_inputList; 00111 00112 }; 00113 00114 #endif 00115 00116 #endif /* XPATHFILTER_HEADER */