commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30298] - evaluate xpath expressions in functions
Date Tue, 03 Aug 2004 08:36:06 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30298>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30298

evaluate xpath expressions in functions





------- Additional Comments From xdury@hotmail.com  2004-08-03 08:36 -------
As I'm still having the same problem with 1.2, I've been digging a little 
deeper: it seems that using setFunctions() on a context doesn't allow me to 
use regular functions anymore.

I'm using the following custom implementation of JXPathContextFactory (which 
worked fine with 1.1):

/**
 * JXPathContextFactory custom implementation.
 * 
 * @author xd
 */
public class JXPathContextFactoryImpl extends 
JXPathContextFactoryReferenceImpl {

    /** The logger. */
    private static Log log = LogFactory.getLog(JXPathContextFactoryImpl.class);

    /** The function library. */
    private static FunctionLibrary library = new FunctionLibrary();

    static {
        log.trace("Initializing JXPath's TypeUtils.");
        TypeUtils.setTypeConverter(DefaultTypeConverter.getInstance());
        log.trace("Initializing JXPath's DefaultFucntions.");
        library.addFunctions(new ClassFunctions
(DefaultFunctions.class, "default"));
    }

    /** Default constructor. */
    public JXPathContextFactoryImpl() {
        log.trace("Instantiating custom JXPathContextFactory...");
    }

    /**
     * @see org.apache.commons.jxpath.JXPathContextFactory#newContext
(org.apache.commons.jxpath.JXPathContext,
     *      java.lang.Object)
     */
    public JXPathContext newContext(JXPathContext inParentContext, Object 
inContextBean) throws JXPathContextFactoryConfigurationError {
        JXPathContext context = super.newContext(inParentContext, 
inContextBean);

        // The context should return null when accessing a non-existing node
        // instead of throwing an exception.
        context.setLenient(true);

        // Set the factory that will create nodes upon hibernate's metadata.
        context.setFactory(AbstractFactoryImpl.getInstance());
        
        // Add some default functions.
        context.setFunctions(library); // THE cause...
        return context;
    }
}

When I remove the 'context.setFunctions(...)' line, I don't have any problem 
anymore.

*** Break ***

After searching in CVS logs with a colleague, we found a way to circumvent the 
problem by doing the following:

library.addFunctions(new PackageFunctions("", null));

At least, it's working! Thanks for your time, I hope I haven't bothered you 
too much!

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message