Xalan-C++ API Reference 1.12.0
ExtensionNSHandler.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#if !defined(XALAN_EXTENSIONNSHANDLER_HEADER_GUARD)
19#define XALAN_EXTENSIONNSHANDLER_HEADER_GUARD
20
21
22// Base include file. Must be first.
23#include "XSLTDefinitions.hpp"
24
25
26
27// Base class
29
30
31
33
34
35
37
38
39
41
42
43
44namespace XALAN_CPP_NAMESPACE {
45
46
47
48class Stylesheet;
49class StylesheetExecutionContext;
50class XalanElement;
51class XalanNode;
52class XalanQName;
53
54
55
57{
58public:
59
60 /**
61 * Construct a new extension namespace handler for a given extension NS.
62 * This doesn't do anything - just hang on to the namespace URI.
63 *
64 * @param namespaceUri extension namespace URI being implemented
65 */
68 MemoryManager& theManager);
69
70 static ExtensionNSHandler*
73 MemoryManager& theManager);
74
75 /**
76 * Construct a new extension namespace handler given all the information
77 * needed.
78 *
79 * @param namespaceUri extension namespace URI being implemented
80 * @param elemNames string containing list of elements of extension NS
81 * @param funcNames string containing list of functions of extension NS
82 * @param lang language of code implementing the extension
83 * @param srcURL value of src attribute (if any) - treated as a URL
84 * or a classname depending on the value of lang. If
85 * srcURL is not null, then scriptSrc is ignored.
86 * @param scriptSrc the actual script code (if any)
87 */
89 MemoryManager& theManager,
93 const XalanDOMString& lang,
95 const XalanDOMString& src);
96
97 /**
98 * Set function local parts of extension NS. Super does the work; I
99 * just record that a component desc has been loaded.
100 *
101 * @param functions whitespace separated list of function names defined
102 * by this extension namespace
103 */
104 virtual void
106
107 /**
108 * Set the script data for this extension NS. Deferred to super for
109 * actual work - only record that a component desc has been loaded.
110 *
111 * @param lang language of the script
112 * @param srcURL value of src attribute (if any) - treated as a URL
113 * or a classname depending on the value of lang. If
114 * srcURL is not null, then scriptSrc is ignored.
115 * @param scriptSrc the actual script code (if any)
116 */
117 virtual void
119 const XalanDOMString& lang,
120 const XalanDOMString& srcURL,
121 const XalanDOMString& scriptSrc);
122
123 /**
124 * Set element local parts of extension NS.
125 *
126 * @param elemNames whitespace separated list of element names defined
127 * by this extension namespace
128 */
129 void
131
132 /**
133 * Tests whether a certain element name is known within this namespace.
134 *
135 * @param element name of the element being tested
136 * @return true if known, false if not
137 */
138 bool
140
141 /**
142 * Process a call to this extension namespace via an element. As a side
143 * effect, the results are sent to the XSLTProcessor's result tree.
144 *
145 * @param localPart element name's local part
146 * @param element extension element being processed
147 * @param stylesheetTree compiled stylesheet tree
148 * @param mode current mode
149 * @param sourceTree root of the source tree (but don't assume it's a
150 * document)
151 * @param sourceNode current context node
152 * @exception XSLProcessorException thrown if something goes wrong
153 * while running the extension handler
154 * @exception MalformedURLException if loading trouble
155 * @exception FileNotFoundException if loading trouble
156 * @exception IOException if loading trouble
157 * @exception SAXException if parsing trouble
158 */
159 void
163 const XalanElement* element,
165 const XalanNode* sourceTree,
166 const XalanNode* sourceNode,
167 const XalanQName& mode);
168
169protected:
170
171 /**
172 * Start the component up by executing any script that needs to run
173 * at startup time. This needs to happen before any functions can be
174 * called on the component.
175 *
176 */
177 virtual void
179
180private:
181
183
184 // Extension elements of this namespace
185 ExtensionSetType m_elements;
186
187 // True when info from the component description has been loaded. This gets
188 // set as soon as any of the info has been specified. If this is false,
189 // when processElement or processFunction is called it will use the
190 // namespace URI as a URL and try to load that location as the component
191 // description
192 bool m_componentDescLoaded;
193
194 /**
195 * Load the component spec for this extension namespace taking the URI
196 * of this namespace as the URL to read from.
197 */
198 void
199 loadComponentDescription();
200
201 /**
202 * extract the text nodes and CDATA content children of the given
203 * elem and return as a string. Any other types of node children
204 * are ignored
205 *
206 * @param elem element whose text and cdata children are to be
207 * concatenated together.
208 *
209 * @return string resulting from concatanating the text/cdata child
210 * nodes' values.
211 */
212 static XalanDOMString&
213 getScriptString(const XalanElement& elem, XalanDOMString& theResult);
214};
215
216
217
218}
219
220
221
222#endif // XALAN_EXTENSIONNSHANDLER_HEADER_GUARD
#define XALAN_XSLT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Class handling an extension namespace for XPath.
virtual void setFunctions(const XalanDOMString &funcNames)
Set function local parts of extension NS.
ExtensionNSHandler(const XalanDOMString &namespaceUri, MemoryManager &theManager)
Construct a new extension namespace handler for a given extension NS.
virtual void setScript(const XalanDOMString &lang, const XalanDOMString &srcURL, const XalanDOMString &scriptSrc)
Set the script data for this extension NS.
ExtensionNSHandler(MemoryManager &theManager, const XalanDOMString &namespaceUri, const XalanDOMString &elemNames, const XalanDOMString &funcNames, const XalanDOMString &lang, const XalanDOMString &srcURL, const XalanDOMString &src)
Construct a new extension namespace handler given all the information needed.
virtual void startupComponent()
Start the component up by executing any script that needs to run at startup time.
static ExtensionNSHandler * create(const XalanDOMString &namespaceUri, MemoryManager &theManager)
void setElements(const XalanDOMString &elemNames)
Set element local parts of extension NS.
bool isElementAvailable(const XalanDOMString &element) const
Tests whether a certain element name is known within this namespace.
void processElement(StylesheetExecutionContext &executionContext, const XalanDOMString &localPart, const XalanElement *element, Stylesheet &stylesheetTree, const XalanNode *sourceTree, const XalanNode *sourceNode, const XalanQName &mode)
Process a call to this extension namespace via an element.
This class represents the base stylesheet or an "import" stylesheet.
Class to represent a qualified name.