If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Friday, September 30, 2011

The power of Apache Cocoon, Xquery, and XSLT extensions

This article describes the use case where you have product data stored in a XML database.
Your customer wants to be able to search products based on (part of) the product name and display
the product properties in a html page. However, all products are also part of a workflow and to find
the status of a particular product we have to fetch information from another system. To fetch the status
this demo includes a MonitorClient which offers needed functionality. The demo describes how to generate the
entire page using purely Apache Cocoon, Xquery and XSLT. The only custom Cocoon component we developed is
the XQueryGenerator which basically reads an xquery from the specified @src attribute, injects any sitemap parameters from the match pattern and returns the results.

PH3330L.xml: Sample data which is stored in XMLDB:

products.xqlib: XQuery library for retrieving products:

products.xquery: returns a xhtml page containing matching products based on their name:

Beans configured in Spring application context:

client.xslt: replaces client:getStatus with actual value

No comments:

Post a Comment