jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Plotnikov" <dmi...@plotnix.com>
Subject [JSPTL] JXPath as yet another expression language
Date Sat, 08 Sep 2001 21:56:56 GMT
JXPath is a component of the Jakarta Commons project.  It is an
implementation of the XPath expression language applied to JavaBeans,
collections, maps, various Servlet artifacts as well as DOM.  The language
itself was standardized by W3C as a common part of XSLT and XPointer.  You
can fully take advantage of JXPath when your application is working with a
mix of Java objects and XML documents (and what application does not these

I implemented an experimental light-weight ExpressionEvaluator for JXPath.
It turned out to be very simple and works like a charm.   Here's the source
of the core method:

public class JXPathExpressionEvaluator implements ExpressionEvaluator {
    public Object evaluate(String attributeName,
            String expression,  Class expectedType,  Tag tag,
            PageContext pageContext) throws JspException {
        try {
            JXPathContext context =
            Object result = context.getValue(expression, expectedType);
            return result != null ? result : "";
        catch (Exception ex){
            throw new JspException(ex.getMessage());

Even with this simplistic implementation, I was able to use XPaths with all
JSPTL tags.

Very exciting!

Question: if we were to add JXPath as yet another expression language to
JSPTL, where would the source code belong?  I don't think we should
introduce dependencies between the JSPTL and JXPath projects.  JXPath is in
commons; it should not depend on anything except commons itself as commons
is supposed to be the foundation for the whole project.  OTOH, JSPTL is
becoming a standard, therefore it should be easily separable from the rest
of Jakarta. Or are these assumptions incorrect?

- Dmitri Plotnikov

View raw message