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: TXFMXPath.hpp,v 1.10 2005/02/03 13:50:12 milan Exp $ 00023 * 00024 */ 00025 00026 #include <xsec/transformers/TXFMBase.hpp> 00027 #include <xsec/utils/XSECSafeBuffer.hpp> 00028 #include <xsec/canon/XSECC14n20010315.hpp> 00029 #include <xsec/dsig/DSIGXPathHere.hpp> 00030 #include <xsec/utils/XSECSafeBufferFormatter.hpp> 00031 00032 // Xerces 00033 00034 XSEC_DECLARE_XERCES_CLASS(DOMNode); 00035 XSEC_DECLARE_XERCES_CLASS(DOMNamedNodeMap); 00036 00037 // Xalan 00038 00039 #ifndef XSEC_NO_XALAN 00040 00041 #include <xalanc/XalanDOM/XalanDocument.hpp> 00042 #include <xalanc/XercesParserLiaison/XercesDocumentWrapper.hpp> 00043 #include <xalanc/XercesParserLiaison/XercesDOMSupport.hpp> 00044 #include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp> 00045 #include <xalanc/XPath/XPathEvaluator.hpp> 00046 #include <xalanc/XPath/XPathProcessorImpl.hpp> 00047 #include <xalanc/XPath/XPathFactoryDefault.hpp> 00048 #include <xalanc/XPath/NodeRefList.hpp> 00049 #include <xalanc/XPath/XPathEnvSupportDefault.hpp> 00050 #include <xalanc/XPath/XPathConstructionContextDefault.hpp> 00051 #include <xalanc/XPath/ElementPrefixResolverProxy.hpp> 00052 00053 #endif 00054 00055 #ifndef XSEC_NO_XPATH 00056 00063 class DSIG_EXPORT TXFMXPath : public TXFMBase { 00064 00065 private: 00066 00067 safeBuffer expr; // The expression being worked with 00068 00069 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * document; 00070 XERCES_CPP_NAMESPACE_QUALIFIER DOMNamedNodeMap * XPathAtts; // Attributes that came through from the doc 00071 00072 static bool XPathInitDone; 00073 00074 DSIGXPathHere * here; // The function to implement here() 00075 XSECSafeBufferFormatter * formatter; 00076 00077 public: 00078 00079 TXFMXPath(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc); 00080 ~TXFMXPath(); 00081 00082 // Methods to set the inputs 00083 00084 void setInput(TXFMBase *newInput); 00085 00086 // Methods to get tranform output type and input requirement 00087 00088 virtual TXFMBase::ioType getInputType(void); 00089 virtual TXFMBase::ioType getOutputType(void); 00090 virtual TXFMBase::nodeType getNodeType(void); 00091 00092 // XPath unique 00093 00094 void setNameSpace(XERCES_CPP_NAMESPACE_QUALIFIER DOMNamedNodeMap *xpAtts); 00095 void evaluateExpr(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *h, safeBuffer expr); 00096 void evaluateEnvelope(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *t); 00097 00098 // Methods to get output data 00099 00100 virtual unsigned int readBytes(XMLByte * const toFill, const unsigned int maxToFill); 00101 virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *getDocument(); 00102 virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *getFragmentNode(); 00103 virtual const XMLCh * getFragmentId(); 00104 virtual XSECXPathNodeList & getXPathNodeList(); 00105 private: 00106 TXFMXPath(); 00107 }; 00108 00109 #endif