dbertoni 2002/12/12 14:24:31
Modified: c/src/XPath XPathExecutionContext.hpp
XPathExecutionContextDefault.cpp
XPathExecutionContextDefault.hpp
Log:
Consistent implementation of elementAvailable() and functionAvailable(). Fix
for bugzilla 14785.
Revision Changes Path
1.54 +32 -11 xml-xalan/c/src/XPath/XPathExecutionContext.hpp
Index: XPathExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContext.hpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- XPathExecutionContext.hpp 26 Nov 2002 01:03:20 -0000 1.53
+++ XPathExecutionContext.hpp 12 Dec 2002 22:24:31 -0000 1.54
@@ -268,28 +268,49 @@
/**
* Determine if an external element is available.
*
- * @param theNamespace namespace for the element
- * @param elementName name of extension element
+ * @param theQName The QName of the element
+ *
+ * @return whether the given element is available or not
+ */
+ virtual bool
+ elementAvailable(const XalanQName& theQName) const = 0;
+
+ /**
+ * Determine if an external element is available by resolving
+ * a string to a QName.
+ *
+ * @param theName The name of the element
+ * @param locator A LocatorType instance for error reporting
+ *
* @return whether the given element is available or not
*/
virtual bool
elementAvailable(
- const XalanDOMString& theNamespace,
- const XalanDOMString& elementName) const = 0;
+ const XalanDOMString& theName,
+ const LocatorType* locator) const = 0;
/**
- * Determine if a function is available. For standard
- * function availability, theNamespace should be an
- * empty string.
+ * Determine if a function is available.
+ *
+ * @param theQName The QName of the function
+ *
+ * @return whether the function is available or not
+ */
+ virtual bool
+ functionAvailable(const XalanQName& theQName) const = 0;
+
+ /**
+ * Determine if a function is available.
+ *
+ * @param theName The name of the function
+ * @param locator A LocatorType instance for error reporting
*
- * @param theNamespace namespace for the function
- * @param functionName name of the function
* @return whether the function is available or not
*/
virtual bool
functionAvailable(
- const XalanDOMString& theNamespace,
- const XalanDOMString& functionName) const = 0;
+ const XalanDOMString& theName,
+ const LocatorType* locator) const = 0;
/**
* Handle an extension function.
1.57 +41 -10 xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp
Index: XPathExecutionContextDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- XPathExecutionContextDefault.cpp 5 Dec 2002 01:43:28 -0000 1.56
+++ XPathExecutionContextDefault.cpp 12 Dec 2002 22:24:31 -0000 1.57
@@ -110,7 +110,8 @@
m_throwFoundIndex(false),
m_nodeListCache(eNodeListCacheListSize),
m_stringCache(),
- m_cachedPosition()
+ m_cachedPosition(),
+ m_scratchQName()
{
}
@@ -128,7 +129,9 @@
m_prefixResolver(thePrefixResolver),
m_throwFoundIndex(false),
m_nodeListCache(eNodeListCacheListSize),
- m_stringCache()
+ m_stringCache(),
+ m_cachedPosition(),
+ m_scratchQName()
{
}
@@ -277,8 +280,8 @@
// If not found, it's 0. Otherwise, it's the index + 1
#if defined(XALAN_NO_MUTABLE)
- (XPathExecutionContextDefault*(this))->m_cachedPosition.m_index
= theIndex == NodeRefListBase::npos ? 0 : theIndex + 1;
- (XPathExecutionContextDefault*(this))->m_cachedPosition.m_node
= &contextNode;
+ ((XPathExecutionContextDefault*)this)->m_cachedPosition.m_index
= theIndex == NodeRefListBase::npos ? 0 : theIndex + 1;
+ ((XPathExecutionContextDefault*)this)->m_cachedPosition.m_node
= &contextNode;
#else
m_cachedPosition.m_index = theIndex == NodeRefListBase::npos ?
0 : theIndex + 1;
m_cachedPosition.m_node = &contextNode;
@@ -291,25 +294,53 @@
bool
+XPathExecutionContextDefault::elementAvailable(const XalanQName&
theQName) const
+{
+ assert(m_xpathEnvSupport != 0);
+
+ return m_xpathEnvSupport->elementAvailable(theQName.getNamespace(),
theQName.getLocalPart());
+}
+
+
+
+bool
XPathExecutionContextDefault::elementAvailable(
- const XalanDOMString& theNamespace,
- const XalanDOMString& elementName) const
+ const XalanDOMString& theName,
+ const LocatorType* theLocator) const
+{
+ assert(m_xpathEnvSupport != 0);
+
+ XalanQNameByValue& theQName = getScratchQName();
+
+ theQName.set(theName, m_prefixResolver, theLocator);
+
+ return elementAvailable(m_scratchQName);
+}
+
+
+
+bool
+XPathExecutionContextDefault::functionAvailable(const XalanQName&
theQName) const
{
assert(m_xpathEnvSupport != 0);
- return m_xpathEnvSupport->elementAvailable(theNamespace, elementName);
+ return m_xpathEnvSupport->functionAvailable(theQName.getNamespace(),
theQName.getLocalPart());
}
bool
XPathExecutionContextDefault::functionAvailable(
- const XalanDOMString& theNamespace,
- const XalanDOMString& functionName) const
+ const XalanDOMString& theName,
+ const LocatorType* theLocator) const
{
assert(m_xpathEnvSupport != 0);
- return m_xpathEnvSupport->functionAvailable(theNamespace, functionName);
+ XalanQNameByValue& theQName = getScratchQName();
+
+ theQName.set(theName, m_prefixResolver, theLocator);
+
+ return functionAvailable(theQName);
}
1.48 +27 -4 xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp
Index: XPathExecutionContextDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- XPathExecutionContextDefault.hpp 4 Dec 2002 21:45:40 -0000 1.47
+++ XPathExecutionContextDefault.hpp 12 Dec 2002 22:24:31 -0000 1.48
@@ -91,6 +91,7 @@
#include <XPath/MutableNodeRefList.hpp>
+#include <XPath/XalanQNameByValue.hpp>
@@ -181,6 +182,20 @@
m_xobjectFactory = theXObjectFactory;
}
+ /**
+ * Get a reference to the scratch QNameByValue instance.
+ *
+ * @return A reference to a QNameByValue instance.
+ */
+ XalanQNameByValue&
+ getScratchQName() const
+ {
+#if defined(XALAN_NO_MUTABLE)
+ return ((XPathExecutionContextDefault*)this)->m_scratchQName;
+#else
+ return m_scratchQName;
+#endif
+ }
// These interfaces are inherited from XPathExecutionContext...
@@ -214,14 +229,20 @@
getContextNodeListPosition(const XalanNode& contextNode)
const;
virtual bool
+ elementAvailable(const XalanQName& theQName) const;
+
+ virtual bool
elementAvailable(
- const XalanDOMString& theNamespace,
- const XalanDOMString& elementName) const;
+ const XalanDOMString& theName,
+ const LocatorType* locator) const;
+
+ virtual bool
+ functionAvailable(const XalanQName& theQName) const;
virtual bool
functionAvailable(
- const XalanDOMString& theNamespace,
- const XalanDOMString& functionName) const;
+ const XalanDOMString& theName,
+ const LocatorType* locator) const;
virtual const XObjectPtr
extFunction(
@@ -394,6 +415,8 @@
XalanDOMStringCache
m_stringCache;
mutable ContextNodeListPositionCache m_cachedPosition;
+
+ mutable XalanQNameByValue m_scratchQName;
static const NodeRefList s_dummyList;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]