dbertoni 01/07/17 21:26:55
Modified: c/src/XPath XPathEnvSupport.hpp XPathEnvSupportDefault.cpp
XPathEnvSupportDefault.hpp
XPathExecutionContext.hpp
XPathExecutionContextDefault.cpp
XPathExecutionContextDefault.hpp
Log:
Implemented better error handling.
Revision Changes Path
1.15 +21 -39 xml-xalan/c/src/XPath/XPathEnvSupport.hpp
Index: XPathEnvSupport.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEnvSupport.hpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XPathEnvSupport.hpp 2001/06/14 19:12:10 1.14
+++ XPathEnvSupport.hpp 2001/07/18 04:26:54 1.15
@@ -215,44 +215,23 @@
/**
* Function that is called when a problem event occurs.
*
- * @param where Either eXMLParser,
eXSLTProcessor,
- * eXPATHParser,
eXPATHProcessor, or
- * eDataSource.
- * @param classification Either eWarning, or eError
- * @param styleNode The style tree node where the problem
- * occurred. May
be null.
- * @param sourceNode The source tree node where the problem
- * occurred. May
be null.
- * @param msg A string message explaining the
problem.
- * @param lineNo The line number where the
problem occurred,
- * if it is known.
May be zero.
- * @param charOffset The character offset where the problem,
- * occurred if it
is known. May be zero.
- *
+ * @param where either eXMLParser,
eXSLTProcessor,
+ *
eXPATHParser, eXPATHProcessor, or eDataSource.
+ * @param classification either eWarning, or eError
+ * @param styleNode style tree node where the problem occurred
+ * (may be 0)
+ * @param sourceNode source tree node where the problem
occurred
+ * (may be 0)
+ * @param msg string message explaining the problem.
+ * @param uri the URI of the stylesheet, if
available. May be 0;
+ * @param lineNo line number where the problem occurred,
+ * if it is known, else -1
+ * @param charOffset character offset where the problem,
+ * occurred if it is known, else -1
* @return true if the return is an ERROR, in which case
- * exception will be thrown. Otherwise the processor
will
- * continue to process.
+ * exception will be thrown. Otherwise the processor will
+ * continue to process.
*/
-
- /**
- * Function that is called when a problem event occurs.
- *
- * @param where either eXMLParser,
eXSLTProcessor,
- *
eXPATHParser, eXPATHProcessor, or eDataSource.
- * @param classification either eWarning, or eError
- * @param styleNode style tree node where the problem occurred
- * (may be null)
- * @param sourceNode source tree node where the problem occurred
- * (may be null)
- * @param msg string message explaining the problem.
- * @param lineNo line number where the problem occurred,
- * if it is known, else zero
- * @param charOffset character offset where the problem,
- * occurred if it is known, else zero
- * @return true if the return is an ERROR, in which case
- * exception will be thrown. Otherwise the processor will
- * continue to process.
- */
virtual bool
problem(
eSource where,
@@ -260,6 +239,7 @@
const XalanNode* styleNode,
const XalanNode* sourceNode,
const XalanDOMString& msg,
+ const XalanDOMChar* uri,
int lineNo,
int
charOffset) const = 0;
@@ -271,12 +251,13 @@
* @param classification either eWarning, or eError
* @param resolver resolver for namespace resolution
* @param sourceNode source tree node where the problem occurred
- * (may be null)
+ * (may be 0)
* @param msg string message explaining the problem.
+ * @param uri the URI of the stylesheet, if
available. May be 0;
* @param lineNo line number where the problem occurred,
- * if it is known, else zero
+ * if it is known, else -1
* @param charOffset character offset where the problem,
- * occurred if it is known, else zero
+ * occurred if it is known, else -1
* @return true if the return is an ERROR, in which case exception will
be
* thrown. Otherwise the processor will continue to process.
*/
@@ -287,6 +268,7 @@
const PrefixResolver* resolver,
const XalanNode* sourceNode,
const XalanDOMString& msg,
+ const XalanDOMChar* uri,
int lineNo,
int
charOffset) const = 0;
1.27 +19 -5 xml-xalan/c/src/XPath/XPathEnvSupportDefault.cpp
Index: XPathEnvSupportDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEnvSupportDefault.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XPathEnvSupportDefault.cpp 2001/06/14 19:12:11 1.26
+++ XPathEnvSupportDefault.cpp 2001/07/18 04:26:54 1.27
@@ -470,11 +470,18 @@
const XalanNode* /* styleNode */,
const XalanNode* /* sourceNode */,
const XalanDOMString& msg,
+ const XalanDOMChar* uri,
int lineNo,
int
charOffset) const
{
- cerr << msg
- << ", at line number "
+ cerr << msg;
+
+ if (uri != 0)
+ {
+ cerr << ",in " << uri;
+ }
+
+ cerr << ", at line number "
<< lineNo
<< " at offset "
<< charOffset
@@ -492,17 +499,24 @@
const PrefixResolver* /* resolver */,
const XalanNode* /* sourceNode */,
const XalanDOMString& msg,
+ const XalanDOMChar* uri,
int lineNo,
int
charOffset) const
{
- cerr << msg
- << ", at line number "
+ cerr << msg;
+
+ if (uri != 0)
+ {
+ cerr << ",in " << uri;
+ }
+
+ cerr << ", at line number "
<< lineNo
<< " at offset "
<< charOffset
<< endl;
- return classification == XPathEnvSupport::eError ? true :false;
+ return classification == XPathEnvSupport::eError ? true : false;
}
1.21 +2 -0 xml-xalan/c/src/XPath/XPathEnvSupportDefault.hpp
Index: XPathEnvSupportDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEnvSupportDefault.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XPathEnvSupportDefault.hpp 2001/06/14 19:12:12 1.20
+++ XPathEnvSupportDefault.hpp 2001/07/18 04:26:54 1.21
@@ -213,6 +213,7 @@
const XalanNode* styleNode,
const XalanNode* sourceNode,
const XalanDOMString& msg,
+ const XalanDOMChar* uri,
int lineNo,
int
charOffset) const;
@@ -223,6 +224,7 @@
const PrefixResolver* resolver,
const XalanNode* sourceNode,
const XalanDOMString& msg,
+ const XalanDOMChar* uri,
int lineNo,
int
charOffset) const;
1.41 +36 -0 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.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- XPathExecutionContext.hpp 2001/05/17 16:12:20 1.40
+++ XPathExecutionContext.hpp 2001/07/18 04:26:54 1.41
@@ -802,11 +802,23 @@
virtual void
error(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const = 0;
+
+ virtual void
+ error(
const char* msg,
const XalanNode* sourceNode = 0,
const XalanNode* styleNode = 0) const = 0;
virtual void
+ error(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const = 0;
+
+ virtual void
warn(
const XalanDOMString& msg,
const XalanNode* sourceNode = 0,
@@ -814,11 +826,23 @@
virtual void
warn(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const = 0;
+
+ virtual void
+ warn(
const char* msg,
const XalanNode* sourceNode = 0,
const XalanNode* styleNode = 0) const = 0;
virtual void
+ warn(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const = 0;
+
+ virtual void
message(
const XalanDOMString& msg,
const XalanNode* sourceNode = 0,
@@ -826,9 +850,21 @@
virtual void
message(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const = 0;
+
+ virtual void
+ message(
const char* msg,
const XalanNode* sourceNode = 0,
const XalanNode* styleNode = 0) const = 0;
+
+ virtual void
+ message(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const = 0;
};
1.40 +222 -25 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.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- XPathExecutionContextDefault.cpp 2001/06/29 18:47:57 1.39
+++ XPathExecutionContextDefault.cpp 2001/07/18 04:26:54 1.40
@@ -62,6 +62,10 @@
+#include <sax/Locator.hpp>
+
+
+
#include <Include/STLHelper.hpp>
@@ -450,7 +454,7 @@
bool
-XPathExecutionContextDefault::shouldStripSourceNode(const XalanNode& node)
+XPathExecutionContextDefault::shouldStripSourceNode(const XalanNode& /* node
*/)
{
return false;
}
@@ -465,15 +469,16 @@
{
assert(m_xpathEnvSupport != 0);
- if (m_xpathEnvSupport->problem(XPathEnvSupport::eXPATHProcessor,
-
XPathEnvSupport::eError,
-
m_prefixResolver,
- sourceNode,
- msg,
- 0,
- 0) == true)
+ if (m_xpathEnvSupport->problem(
+ XPathEnvSupport::eXPATHProcessor,
+ XPathEnvSupport::eError,
+ m_prefixResolver,
+ sourceNode,
+ msg,
+ 0,
+ -1,
+ -1) == true)
{
- // $$$ ToDo: Do something with the PrefixResolver here...
throw XPathException(msg, 0);
}
}
@@ -482,6 +487,58 @@
void
XPathExecutionContextDefault::error(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const
+{
+ assert(m_xpathEnvSupport != 0);
+
+ int lineNumber = -1;
+ int columnNumber = -1;
+
+ XalanDOMString uri;
+
+ if (locator != 0)
+ {
+ lineNumber = locator->getLineNumber();
+ columnNumber = locator->getColumnNumber();
+
+ const XalanDOMChar* id =
+ locator->getPublicId();
+
+ if (id != 0)
+ {
+ uri = id;
+ }
+ else
+ {
+ id = locator->getSystemId();
+
+ if (id != 0)
+ {
+ uri = id;
+ }
+ }
+ }
+
+ if (m_xpathEnvSupport->problem(
+ XPathEnvSupport::eXPATHProcessor,
+ XPathEnvSupport::eError,
+ m_prefixResolver,
+ sourceNode,
+ msg,
+ c_wstr(uri),
+ lineNumber,
+ columnNumber) == true)
+ {
+ throw XPathException(msg, uri, lineNumber, columnNumber);
+ }
+}
+
+
+
+void
+XPathExecutionContextDefault::error(
const char* msg,
const XalanNode* sourceNode,
const XalanNode* styleNode) const
@@ -492,6 +549,17 @@
void
+XPathExecutionContextDefault::error(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const
+{
+ error(TranscodeFromLocalCodePage(msg), sourceNode, locator);
+}
+
+
+
+void
XPathExecutionContextDefault::warn(
const XalanDOMString& msg,
const XalanNode* sourceNode,
@@ -499,17 +567,70 @@
{
assert(m_xpathEnvSupport != 0);
- if (m_xpathEnvSupport->problem(XPathEnvSupport::eXPATHProcessor,
-
XPathEnvSupport::eWarning,
-
m_prefixResolver,
- sourceNode,
- msg,
- 0,
- 0) == true)
+ if (m_xpathEnvSupport->problem(
+ XPathEnvSupport::eXPATHProcessor,
+ XPathEnvSupport::eWarning,
+ m_prefixResolver,
+ sourceNode,
+ msg,
+ 0,
+ -1,
+ -1) == true)
{
- // $$$ ToDo: Do something with the PrefixResolver here...
- throw XPathException(msg, 0);
+ throw XPathException(msg, sourceNode);
+ }
+}
+
+
+
+void
+XPathExecutionContextDefault::warn(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const
+{
+ assert(m_xpathEnvSupport != 0);
+
+ int lineNumber = -1;
+ int columnNumber = -1;
+
+ XalanDOMString uri;
+
+ if (locator != 0)
+ {
+ lineNumber = locator->getLineNumber();
+ columnNumber = locator->getColumnNumber();
+
+ const XalanDOMChar* id =
+ locator->getPublicId();
+
+ if (id != 0)
+ {
+ uri = id;
+ }
+ else
+ {
+ id = locator->getSystemId();
+
+ if (id != 0)
+ {
+ uri = id;
+ }
+ }
}
+
+ if (m_xpathEnvSupport->problem(
+ XPathEnvSupport::eXPATHProcessor,
+ XPathEnvSupport::eWarning,
+ m_prefixResolver,
+ sourceNode,
+ msg,
+ c_wstr(uri),
+ lineNumber,
+ columnNumber) == true)
+ {
+ throw XPathException(msg, uri, lineNumber, columnNumber);
+ }
}
@@ -526,6 +647,17 @@
void
+XPathExecutionContextDefault::warn(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const
+{
+ warn(TranscodeFromLocalCodePage(msg), sourceNode, locator);
+}
+
+
+
+void
XPathExecutionContextDefault::message(
const XalanDOMString& msg,
const XalanNode* sourceNode,
@@ -533,13 +665,15 @@
{
assert(m_xpathEnvSupport != 0);
- if (m_xpathEnvSupport->problem(XPathEnvSupport::eXPATHProcessor,
-
XPathEnvSupport::eMessage,
-
m_prefixResolver,
- sourceNode,
- msg,
- 0,
- 0) == true)
+ if (m_xpathEnvSupport->problem(
+ XPathEnvSupport::eXPATHProcessor,
+ XPathEnvSupport::eMessage,
+ m_prefixResolver,
+ sourceNode,
+ msg,
+ 0,
+ -1,
+ -1) == true)
{
// $$$ ToDo: Do something with the PrefixResolver here...
throw XPathException(msg);
@@ -550,6 +684,58 @@
void
XPathExecutionContextDefault::message(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const
+{
+ assert(m_xpathEnvSupport != 0);
+
+ int lineNumber = -1;
+ int columnNumber = -1;
+
+ XalanDOMString uri;
+
+ if (locator != 0)
+ {
+ lineNumber = locator->getLineNumber();
+ columnNumber = locator->getColumnNumber();
+
+ const XalanDOMChar* id =
+ locator->getPublicId();
+
+ if (id != 0)
+ {
+ uri = id;
+ }
+ else
+ {
+ id = locator->getSystemId();
+
+ if (id != 0)
+ {
+ uri = id;
+ }
+ }
+ }
+
+ if (m_xpathEnvSupport->problem(
+ XPathEnvSupport::eXPATHProcessor,
+ XPathEnvSupport::eMessage,
+ m_prefixResolver,
+ sourceNode,
+ msg,
+ c_wstr(uri),
+ lineNumber,
+ columnNumber) == true)
+ {
+ throw XPathException(msg, uri, lineNumber, columnNumber);
+ }
+}
+
+
+
+void
+XPathExecutionContextDefault::message(
const char* msg,
const XalanNode* sourceNode,
const XalanNode* styleNode) const
@@ -559,6 +745,17 @@
+void
+XPathExecutionContextDefault::message(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const
+{
+ message(TranscodeFromLocalCodePage(msg), sourceNode, locator);
+}
+
+
+
bool
XPathExecutionContextDefault::getThrowFoundIndex() const
{
1.36 +36 -0 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.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- XPathExecutionContextDefault.hpp 2001/05/14 01:01:16 1.35
+++ XPathExecutionContextDefault.hpp 2001/07/18 04:26:54 1.36
@@ -317,11 +317,23 @@
virtual void
error(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const;
+
+ virtual void
+ error(
const char* msg,
const XalanNode* sourceNode = 0,
const XalanNode* styleNode = 0) const;
virtual void
+ error(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const;
+
+ virtual void
warn(
const XalanDOMString& msg,
const XalanNode* sourceNode = 0,
@@ -329,11 +341,23 @@
virtual void
warn(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const;
+
+ virtual void
+ warn(
const char* msg,
const XalanNode* sourceNode = 0,
const XalanNode* styleNode = 0) const;
virtual void
+ warn(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const;
+
+ virtual void
message(
const XalanDOMString& msg,
const XalanNode* sourceNode = 0,
@@ -341,9 +365,21 @@
virtual void
message(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const;
+
+ virtual void
+ message(
const char* msg,
const XalanNode* sourceNode = 0,
const XalanNode* styleNode = 0) const;
+
+ virtual void
+ message(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const Locator* locator) const;
protected:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]