Example usage for org.apache.commons.jxpath PackageFunctions PackageFunctions

List of usage examples for org.apache.commons.jxpath PackageFunctions PackageFunctions

Introduction

In this page you can find the example usage for org.apache.commons.jxpath PackageFunctions PackageFunctions.

Prototype

public PackageFunctions(String classPrefix, String namespace) 

Source Link

Document

Create a new PackageFunctions.

Usage

From source file:org.apache.cocoon.components.modules.input.JXPathHelperConfiguration.java

/**
 * Create root jxpath configuration//from   www.  jav  a 2s.c om
 */
public JXPathHelperConfiguration(Configuration config) throws ConfigurationException {
    this.lenient = config.getChild("lenient").getValueAsBoolean(true);
    this.library = new FunctionLibrary();
    setup(config);

    // the following is necessary to be able to use methods on objects without
    // explicitely registering extension functions (see PackageFunctions javadoc)
    this.library.addFunctions(new PackageFunctions("", null));
}

From source file:org.apache.cocoon.components.modules.input.JXPathHelperConfiguration.java

/**
 * Register all extension packages listed in the configuration
 * through <code>&lt;package name="fully.qualified.package"
 * prefix="prefix"/&gt;</code> in the given FunctionLibrary.
 *
 * @param conf a <code>Configuration</code> value
 */// ww  w  .j a  v  a  2s.c  o  m
private void getPackages(Configuration conf) {

    Configuration[] children = conf.getChildren("package");
    int i = children.length;
    while (i-- > 0) {
        String packageName = children[i].getAttribute("name", null);
        String prefix = children[i].getAttribute("prefix", null);
        if (packageName != null && prefix != null) {
            this.library.addFunctions(new PackageFunctions(packageName, prefix));
        }
    }
}