dbertoni 00/05/29 15:34:32
Modified: c/src/XSLT ExtensionNSHandler.cpp ExtensionNSHandler.hpp
Log:
Remove XSLTProcessor reference, since maintaining this is not thread-safe.
Revision Changes Path
1.5 +61 -59 xml-xalan/c/src/XSLT/ExtensionNSHandler.cpp
Index: ExtensionNSHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ExtensionNSHandler.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExtensionNSHandler.cpp 2000/03/01 20:43:42 1.4
+++ ExtensionNSHandler.cpp 2000/05/29 22:34:32 1.5
@@ -65,7 +65,7 @@
#include <cassert>
-#include <dom/DOM_Element.hpp>
+#include <XalanDOM/XalanElement.hpp>
@@ -80,42 +80,44 @@
struct XSLProcessorContext
{
- const XSLTProcessor& m_processor;
- const Stylesheet& m_stylesheetTree;
- const DOM_Node& m_sourceTree;
- const DOM_Node& m_sourceNode;
- const QName& m_mode;
-
- XSLProcessorContext(
- const XSLTProcessor& processor,
- const Stylesheet& stylesheetTree,
- const DOM_Node& sourceTree,
- const DOM_Node& sourceNode,
- const QName& mode) :
- m_processor(processor),
- m_stylesheetTree(stylesheetTree),
- m_mode(mode),
- m_sourceTree(sourceTree),
- m_sourceNode(sourceNode)
- {}
+ const XSLTProcessor& m_processor;
+ const Stylesheet& m_stylesheetTree;
+ const XalanNode* m_sourceTree;
+ const XalanNode* m_sourceNode;
+ const QName& m_mode;
+
+ XSLProcessorContext(
+ const XSLTProcessor& processor,
+ const Stylesheet& stylesheetTree,
+ const XalanNode* sourceTree,
+ const XalanNode* sourceNode,
+ const QName& mode) :
+ m_processor(processor),
+ m_stylesheetTree(stylesheetTree),
+ m_sourceTree(sourceTree),
+ m_sourceNode(sourceNode),
+ m_mode(mode)
+ {
+ }
};
+
+
/**
* Construct a new extension namespace handler for a given extension NS.
* This doesn't do anything - just hang on to the namespace URI.
*
- * @param xslp handle to the XSL processor
that I'm working for
* @param namespaceUri the extension namespace URI that I'm implementing
*/
-ExtensionNSHandler::ExtensionNSHandler(XSLTProcessor& xslp,
- const DOMString&
namespaceUri) :
+ExtensionNSHandler::ExtensionNSHandler(const XalanDOMString&
namespaceUri) :
ExtensionFunctionHandler(namespaceUri),
- m_XSLProcessor(xslp),
m_elements(),
m_componentDescLoaded(false)
{
}
+
+
/**
* Construct a new extension namespace handler given all the information
* needed.
@@ -131,15 +133,13 @@
* @param scriptSrc the actual script code (if any)
*/
ExtensionNSHandler::ExtensionNSHandler (
- XSLTProcessor& xslp,
- const DOMString& namespaceUri,
- const DOMString& elemNames,
- const DOMString& funcNames,
- const DOMString& lang,
- const DOMString& srcURL,
- const DOMString& src) :
+ const XalanDOMString& namespaceUri,
+ const XalanDOMString& elemNames,
+ const XalanDOMString& funcNames,
+ const XalanDOMString& lang,
+ const XalanDOMString& srcURL,
+ const XalanDOMString& src) :
ExtensionFunctionHandler (namespaceUri, funcNames, lang,
srcURL, src),
- m_XSLProcessor(xslp),
m_elements(),
m_componentDescLoaded(true)
@@ -147,6 +147,8 @@
setElements (elemNames);
}
+
+
/////////////////////////////////////////////////////////////////////////
// Main API
/////////////////////////////////////////////////////////////////////////
@@ -158,7 +160,7 @@
* @param functions whitespace separated list of function names defined
* by this extension namespace.
*/
-void ExtensionNSHandler::setFunctions (const DOMString& funcNames)
+void ExtensionNSHandler::setFunctions (const XalanDOMString& funcNames)
{
ExtensionFunctionHandler::setFunctions (funcNames);
m_componentDescLoaded = true;
@@ -176,7 +178,7 @@
* srcURL
is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
-void ExtensionNSHandler::setScript (const DOMString& lang, const DOMString&
srcURL, const DOMString& scriptSrc)
+void ExtensionNSHandler::setScript (const XalanDOMString& lang, const
XalanDOMString& srcURL, const XalanDOMString& scriptSrc)
{
ExtensionFunctionHandler::setScript (lang, srcURL, scriptSrc);
m_componentDescLoaded = true;
@@ -190,14 +192,14 @@
* @param elemNames whitespace separated list of element names defined
* by this extension namespace.
*/
-void ExtensionNSHandler::setElements (const DOMString& elemNames)
+void ExtensionNSHandler::setElements (const XalanDOMString& elemNames)
{
if (elemNames.length() == 0)
return;
StringTokenizer st(elemNames, " \t\n\r", false);
while (st.hasMoreTokens())
{
- DOMString tok = st.nextToken();
+ XalanDOMString tok = st.nextToken();
m_elements.insert(tok); // just stick it in there basically
}
m_componentDescLoaded = true;
@@ -210,7 +212,7 @@
* @param element name of the element being tested
* @return true if its known, false if not.
*/
-bool ExtensionNSHandler::isElementAvailable (const DOMString& element)
+bool ExtensionNSHandler::isElementAvailable (const XalanDOMString& element)
{
return (m_elements.find(element) != m_elements.end());
}
@@ -237,14 +239,15 @@
* @exception IOException if loading
trouble
* @exception SAXException if parsing
trouble
*/
-void ExtensionNSHandler::processElement (
- const DOMString& localPart,
- const DOM_Element& /* element */,
- XSLTProcessor& processor,
- Stylesheet& stylesheetTree,
- const DOM_Node& sourceTree,
- const DOM_Node& sourceNode,
- const QName& mode)
+void
+ExtensionNSHandler::processElement(
+ const XalanDOMString& localPart,
+ const XalanElement* /* element */,
+ XSLTProcessor& processor,
+ Stylesheet& stylesheetTree,
+ const XalanNode* sourceTree,
+ const XalanNode* sourceNode,
+ const QName& mode)
{
const XObject* result = 0;
@@ -299,7 +302,8 @@
*
* @exception XPathProcessorException if something bad happens.
*/
-void ExtensionNSHandler::startupComponent()
+void
+ExtensionNSHandler::startupComponent()
{
if (!m_componentDescLoaded)
{
@@ -329,7 +333,8 @@
* @exception IOException if loading
trouble
* @exception SAXException if parsing
trouble
*/
-void ExtensionNSHandler::loadComponentDescription ()
+void
+ExtensionNSHandler::loadComponentDescription()
{
// First try treaing the URI of the extension as a fully qualified
// class name; if it works then go with treating this an extension
@@ -397,26 +402,23 @@
* @return string resulting from concatenating the text/cdata child
* nodes' values.
*/
-DOMString ExtensionNSHandler::getScriptString (const DOM_Element& elem)
+XalanDOMString
+ExtensionNSHandler::getScriptString(const XalanElement& elem)
{
- DOMString strBuf;
- for (DOM_Node n = elem.getFirstChild (); n != 0; n = n.getNextSibling
())
+ XalanDOMString strBuf;
+
+ for (const XalanNode* n = elem.getFirstChild (); n != 0; n =
n->getNextSibling ())
{
- switch (n.getNodeType())
+ switch (n->getNodeType())
{
- case DOM_Node::TEXT_NODE:
- case DOM_Node::CDATA_SECTION_NODE:
- strBuf += n.getNodeValue();
+ case XalanNode::TEXT_NODE:
+ case XalanNode::CDATA_SECTION_NODE:
+ strBuf += n->getNodeValue();
break;
default:
break;
}
}
+
return strBuf;
}
-
-
-/*
- * $ Log: $
- */
-
1.4 +47 -46 xml-xalan/c/src/XSLT/ExtensionNSHandler.hpp
Index: ExtensionNSHandler.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ExtensionNSHandler.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExtensionNSHandler.hpp 2000/02/29 20:54:22 1.3
+++ ExtensionNSHandler.hpp 2000/05/29 22:34:32 1.4
@@ -57,6 +57,7 @@
#if !defined(XALAN_EXTENSIONNSHANDLER_HEADER_GUARD)
#define XALAN_EXTENSIONNSHANDLER_HEADER_GUARD
+
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
@@ -69,15 +70,16 @@
#include <set>
+
-#include <dom/DOMString.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
-class DOM_Node;
-class DOM_Element;
class QName;
class Stylesheet;
+class XalanElement;
+class XalanNode;
class XSLTProcessor;
@@ -89,16 +91,14 @@
* Construct a new extension namespace handler for a given extension NS.
* This doesn't do anything - just hang on to the namespace URI.
*
- * @param xslp handle to the XSL processor calling the function
* @param namespaceUri extension namespace URI being implemented
*/
- ExtensionNSHandler(XSLTProcessor& xslp, const DOMString& namespaceUri);
+ ExtensionNSHandler(const XalanDOMString& namespaceUri);
/**
* Construct a new extension namespace handler given all the information
* needed.
*
- * @param xslp handle to the XSL processor calling the function
* @param namespaceUri extension namespace URI being implemented
* @param elemNames string containing list of elements of extension
NS
* @param funcNames string containing list of functions of extension
NS
@@ -108,14 +108,13 @@
* srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
- ExtensionNSHandler (
- XSLTProcessor& xslp,
- const DOMString& namespaceUri,
- const DOMString& elemNames,
- const DOMString& funcNames,
- const DOMString& lang,
- const DOMString& srcURL,
- const DOMString& src);
+ ExtensionNSHandler(
+ const XalanDOMString& namespaceUri,
+ const XalanDOMString& elemNames,
+ const XalanDOMString& funcNames,
+ const XalanDOMString& lang,
+ const XalanDOMString& srcURL,
+ const XalanDOMString& src);
/**
* Set function local parts of extension NS. Super does the work; I
@@ -124,8 +123,8 @@
* @param functions whitespace separated list of function names defined
* by this extension namespace
*/
- virtual void setFunctions (const DOMString& funcNames);
-
+ virtual void
+ setFunctions(const XalanDOMString& funcNames);
/**
* Set the script data for this extension NS. Deferred to super for
@@ -137,7 +136,11 @@
* srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
- virtual void setScript(const DOMString& lang, const DOMString& srcURL,
const DOMString& scriptSrc);
+ virtual void
+ setScript(
+ const XalanDOMString& lang,
+ const XalanDOMString& srcURL,
+ const XalanDOMString& scriptSrc);
/**
@@ -146,7 +149,8 @@
* @param elemNames whitespace separated list of element names defined
* by this extension namespace
*/
- void setElements (const DOMString& elemNames);
+ void
+ setElements(const XalanDOMString& elemNames);
/**
@@ -155,7 +159,8 @@
* @param element name of the element being tested
* @return true if known, false if not
*/
- bool isElementAvailable (const DOMString& element);
+ bool
+ isElementAvailable (const XalanDOMString& element);
/**
@@ -177,14 +182,15 @@
* @exception IOException if loading trouble
* @exception SAXException if parsing trouble
*/
- void processElement (
- const DOMString& localPart,
- const DOM_Element& element,
- XSLTProcessor& processor,
- Stylesheet& stylesheetTree,
- const DOM_Node& sourceTree,
- const DOM_Node& sourceNode,
- const QName& mode);
+ void
+ processElement (
+ const XalanDOMString& localPart,
+ const XalanElement* element,
+ XSLTProcessor& processor,
+ Stylesheet& stylesheetTree,
+ const XalanNode* sourceTree,
+ const XalanNode* sourceNode,
+ const QName& mode);
protected:
@@ -193,18 +199,21 @@
* at startup time. This needs to happen before any functions can be
* called on the component.
*
- * @exception XPathProcessorException if something bad happens.
*/
- virtual void startupComponent(); //throws
XPathProcessorException;
+ virtual void
+ startupComponent();
private:
- XSLTProcessor& m_XSLProcessor; // xsl processor for whom I'm working
+#if defined(XALAN_NO_NAMESPACES)
+ typedef set<XalanDOMString> ExtensionSetType;
+#else
+ typedef std::set<XalanDOMString> ExtensionSetType;
+#endif
// Extension elements of this namespace
- typedef std::set<DOMString> ExtensionSetType;
- ExtensionSetType m_elements;
+ ExtensionSetType m_elements;
// True when info from the component description has been loaded. This
gets
// set as soon as any of the info has been specified. If this is false,
@@ -216,14 +225,9 @@
/**
* Load the component spec for this extension namespace taking the URI
* of this namespace as the URL to read from.
- *
- * @exception XSLProcessorException if something bad happens.
- * @exception MalformedURLException if loading trouble
- * @exception FileNotFoundException if loading trouble
- * @exception IOException if
loading trouble
- * @exception SAXException if
parsing trouble
*/
- void loadComponentDescription ();
+ void
+ loadComponentDescription();
/**
* extract the text nodes and CDATA content children of the given
@@ -236,13 +240,10 @@
* @return string resulting from concatanating the text/cdata child
* nodes' values.
*/
- DOMString getScriptString (const DOM_Element& elem);
-
-}; // end ExtensionNSHandler class definition
+ static XalanDOMString
+ getScriptString(const XalanElement& elem);
+};
-#endif // XALAN_EXTENSIONNSHANDLER_HEADER_GUARD
-/*
- * $ Log: $
- */
+#endif // XALAN_EXTENSIONNSHANDLER_HEADER_GUARD