00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XALAN_EXTENSIONNSHANDLER_HEADER_GUARD) 00019 #define XALAN_EXTENSIONNSHANDLER_HEADER_GUARD 00020 00021 00022 // Base include file. Must be first. 00023 #include "XSLTDefinitions.hpp" 00024 00025 00026 00027 // Base class 00028 #include "ExtensionFunctionHandler.hpp" 00029 00030 00031 00032 #include <xalanc/Include/XalanSet.hpp> 00033 00034 00035 00036 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00037 00038 00039 00040 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00041 00042 00043 00044 XALAN_CPP_NAMESPACE_BEGIN 00045 00046 00047 00048 class Stylesheet; 00049 class StylesheetExecutionContext; 00050 class XalanElement; 00051 class XalanNode; 00052 class XalanQName; 00053 00054 00055 00056 class XALAN_XSLT_EXPORT ExtensionNSHandler : public ExtensionFunctionHandler 00057 { 00058 public: 00059 00060 /** 00061 * Construct a new extension namespace handler for a given extension NS. 00062 * This doesn't do anything - just hang on to the namespace URI. 00063 * 00064 * @param namespaceUri extension namespace URI being implemented 00065 */ 00066 ExtensionNSHandler( 00067 const XalanDOMString& namespaceUri, 00068 MemoryManager& theManager); 00069 00070 static ExtensionNSHandler* 00071 create( 00072 const XalanDOMString& namespaceUri, 00073 MemoryManager& theManager); 00074 00075 /** 00076 * Construct a new extension namespace handler given all the information 00077 * needed. 00078 * 00079 * @param namespaceUri extension namespace URI being implemented 00080 * @param elemNames string containing list of elements of extension NS 00081 * @param funcNames string containing list of functions of extension NS 00082 * @param lang language of code implementing the extension 00083 * @param srcURL value of src attribute (if any) - treated as a URL 00084 * or a classname depending on the value of lang. If 00085 * srcURL is not null, then scriptSrc is ignored. 00086 * @param scriptSrc the actual script code (if any) 00087 */ 00088 ExtensionNSHandler( 00089 MemoryManager& theManager, 00090 const XalanDOMString& namespaceUri, 00091 const XalanDOMString& elemNames, 00092 const XalanDOMString& funcNames, 00093 const XalanDOMString& lang, 00094 const XalanDOMString& srcURL, 00095 const XalanDOMString& src); 00096 00097 /** 00098 * Set function local parts of extension NS. Super does the work; I 00099 * just record that a component desc has been loaded. 00100 * 00101 * @param functions whitespace separated list of function names defined 00102 * by this extension namespace 00103 */ 00104 virtual void 00105 setFunctions(const XalanDOMString& funcNames); 00106 00107 /** 00108 * Set the script data for this extension NS. Deferred to super for 00109 * actual work - only record that a component desc has been loaded. 00110 * 00111 * @param lang language of the script 00112 * @param srcURL value of src attribute (if any) - treated as a URL 00113 * or a classname depending on the value of lang. If 00114 * srcURL is not null, then scriptSrc is ignored. 00115 * @param scriptSrc the actual script code (if any) 00116 */ 00117 virtual void 00118 setScript( 00119 const XalanDOMString& lang, 00120 const XalanDOMString& srcURL, 00121 const XalanDOMString& scriptSrc); 00122 00123 /** 00124 * Set element local parts of extension NS. 00125 * 00126 * @param elemNames whitespace separated list of element names defined 00127 * by this extension namespace 00128 */ 00129 void 00130 setElements(const XalanDOMString& elemNames); 00131 00132 /** 00133 * Tests whether a certain element name is known within this namespace. 00134 * 00135 * @param element name of the element being tested 00136 * @return true if known, false if not 00137 */ 00138 bool 00139 isElementAvailable (const XalanDOMString& element) const; 00140 00141 /** 00142 * Process a call to this extension namespace via an element. As a side 00143 * effect, the results are sent to the XSLTProcessor's result tree. 00144 * 00145 * @param localPart element name's local part 00146 * @param element extension element being processed 00147 * @param stylesheetTree compiled stylesheet tree 00148 * @param mode current mode 00149 * @param sourceTree root of the source tree (but don't assume it's a 00150 * document) 00151 * @param sourceNode current context node 00152 * @exception XSLProcessorException thrown if something goes wrong 00153 * while running the extension handler 00154 * @exception MalformedURLException if loading trouble 00155 * @exception FileNotFoundException if loading trouble 00156 * @exception IOException if loading trouble 00157 * @exception SAXException if parsing trouble 00158 */ 00159 void 00160 processElement ( 00161 StylesheetExecutionContext& executionContext, 00162 const XalanDOMString& localPart, 00163 const XalanElement* element, 00164 Stylesheet& stylesheetTree, 00165 const XalanNode* sourceTree, 00166 const XalanNode* sourceNode, 00167 const XalanQName& mode); 00168 00169 protected: 00170 00171 /** 00172 * Start the component up by executing any script that needs to run 00173 * at startup time. This needs to happen before any functions can be 00174 * called on the component. 00175 * 00176 */ 00177 virtual void 00178 startupComponent(); 00179 00180 private: 00181 00182 typedef XalanSet<XalanDOMString> ExtensionSetType; 00183 00184 // Extension elements of this namespace 00185 ExtensionSetType m_elements; 00186 00187 // True when info from the component description has been loaded. This gets 00188 // set as soon as any of the info has been specified. If this is false, 00189 // when processElement or processFunction is called it will use the 00190 // namespace URI as a URL and try to load that location as the component 00191 // description 00192 bool m_componentDescLoaded; 00193 00194 /** 00195 * Load the component spec for this extension namespace taking the URI 00196 * of this namespace as the URL to read from. 00197 */ 00198 void 00199 loadComponentDescription(); 00200 00201 /** 00202 * extract the text nodes and CDATA content children of the given 00203 * elem and return as a string. Any other types of node children 00204 * are ignored 00205 * 00206 * @param elem element whose text and cdata children are to be 00207 * concatenated together. 00208 * 00209 * @return string resulting from concatanating the text/cdata child 00210 * nodes' values. 00211 */ 00212 static XalanDOMString& 00213 getScriptString(const XalanElement& elem, XalanDOMString& theResult); 00214 }; 00215 00216 00217 00218 XALAN_CPP_NAMESPACE_END 00219 00220 00221 00222 #endif // XALAN_EXTENSIONNSHANDLER_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|