Hi, Tahura.
"Tahura Chaudhry" <[EMAIL PROTECTED]> wrote on 2005-01-28 06:35:35 PM:
> In my application, I provide a UI to allow the user to enter an XPath
> expression. I call Xalan's XPathEvaluator.evaluate(....) to determine
if
> they syntax of the entered expression is valid. If evalute() throws a
> DOMException or an XPathException, I assume that the XPath syntax is
invalid
> and notify the user. I also display the exception string
> (exception.getMessage()) to the user in the UI.
>
> This works well for most cases. However I have come across a case in
which
> entering an invalid syntax leads to a java.lang.RuntimeException.
>
> The XPath expression that causes this is:
> [EMAIL PROTECTED]"manager"] and
>
> I can't assume that the RuntimeException will always be thrown because
of
> invalid syntax.
>
> Is there a better way to validate the syntax of the XPath expression?
>
> The entire exception trace resulting from calling evalute() on the above
> XPath expression is shown below:
>
> [java] java.lang.RuntimeException: Programmer's assertion in
> getNextStepPos: unknown stepType:
> -1
Catching DOMExceptions and XPathExceptions is the correct way to
check for expressions that do not match the XPath syntax or other problems
in evaluating XPath expressions. RuntimeExceptions thrown by Xalan-J
Interpretive while parsing XPath expressions are usually caused by bugs in
the XPath parser. This particular problem was previously reported as
XALANJ-1478.[1]
I'll take a look to see whether I can resolve this bug in parsing
XPath expressions.
Thanks,
Henry
[1] http://issues.apache.org/jira/browse/XALANJ-1478
------------------------------------------------------------------
Henry Zongaro Xalan development
IBM SWS Toronto Lab T/L 969-6044; Phone +1 905 413-6044
mailto:[EMAIL PROTECTED]