TSSS - XQuery and XQJ
As you might have noticed I am pretty bullish on
XQuery as a good solution to XML problems. XQJ is a new API to use it from
Java.
The XQJ API (JSR-225) is currently in early draft
at the JCP. Currently I use the Saxon API in the work I do with XQuery. Here
is an example from mjg.md:
Configuration c = new Configuration();
StaticQueryContext qp = new StaticQueryContext(c);
XQueryExpression xe = qp.compileQuery(query);
DynamicQueryContext dqc = new DynamicQueryContext(c);
Source source = new StreamSource(new URL(url).openStream());
DocumentInfo di = qp.buildDocument(source);
dqc.setContextNode(di);
List result = xe.evaluate(dqc);
The result is a List of DOM elements that are the result of the query. I was hoping he would talk more about using XQuery against relational databases which I think is a powerful way to display relational data in markup. You ought to be able to directly transform most XQueries directly into their SQL equivalents. The speakers product has this sort of thing but I imagine a standard transform would be generally useful through a new XQuery function that allows relational source documents. Here is what the standard API will look like:
XQConnection conn = xqds.getConnection();
XQExpression expr = conn.createExpression();
XQResultSequence result = expr.executeQuery(query);
A little less verbose with a more J2EE feel
to it. I'd really need to try it out to see what I
think.The next talk I went to is the
XQuery talk by Jason Hunter. His company has a large XML repository that is
accessed through XQuery. The talk is similar to the talk last year with a new
demo and some information about XQJ. Unfortunately, his talk focuses on using
XQuery against an XML database instead of at runtime. Most of the use cases for
me involve processing transient XML messages.
Posted: Sat
- March 5, 2005 at 04:12 PM
|