Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Custom XPath functions

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Lance Eason <leason AT betweenmarkets.com>
  • Cc: Guilherme Germoglio <germoglio AT gmail.com>, xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Custom XPath functions
  • Date: Sat, 16 Sep 2006 15:05:09 -0400

Lance Eason wrote:
We had a similar need. The way we approached it was to use Jaxen's
ability to register a Java class containing custom functions via a
namespace declaration. We wrapped adding that declaration to
XPath/XQuery expressions within a utility function:

It looks like you're using NUX, not XOM; and XQuery instead of XPath. if that's an option, that might be the simplest approach.


public class XQueryUtil
{
public static Nodes xquery(Node node, String xpath)
{
// automatically make our custom functions available
xpath = "declare namespace
big='java:com.betweenmarkets.document.BMIFunctions';\n" + xpath;
return nux.xom.xquery.XQueryUtil.xquery(node, xpath);
}
}




--
Elliotte Rusty Harold elharo AT metalab.unc.edu
Java I/O 2nd Edition Just Published!
http://www.cafeaulait.org/books/javaio2/
http://www.amazon.com/exec/obidos/ISBN=0596527500/ref=nosim/cafeaulaitA/




Archive powered by MHonArc 2.6.24.

Top of Page