XQuery in PHP 5 with Zorba

Have you wondered how you can harness the power of XQuery with PHP? Well, the response is: Zorba
Zorba I used a few years ago and has recently grown so much. For me, Zorba, is the most complete XQuery Processor.

The major strong points of Zorba can be summarized as:

  • All Flavors Available
  • Rich XQuery Library
  • Pluggable Store
  • Runs Everywhere
  • Developer Friendly Tools

Zorba, supports, although currently only partially (read W3C XQuery 3.0 Partial Support), the specifications of the W3C XQuery 3.0.

You can try immediately (online), XQuery 3.0 support via Zorba XQuery. Below is an example of XQuery for grouping (3.10.7 Group By Clause).

<result>{
 for $sales in doc("sales-records.xml")/*/record
 let $state := doc("stores.xml")/*/store[store-number = $sales/store-number]/state,
 $product := doc("products.xml")/*/product[name = $sales/product-name],
 $category := $product/category,
 $revenue := $sales/qty * $product/price
 group by $state, $category
 order by $state, $category
 return
 <group>
 {$state, $category}
 <total-revenue>{sum($revenue)}</total-revenue>
 </group> 
}</result>

Code 1. Example of XQuery grouping.

Zorba resources

Antonio Musarra

I began my journey into the world of computing from an Olivetti M24 PC (http://it.wikipedia.org/wiki/Olivetti_M24) bought by my father for his work. Day after day, quickly taking control until … Now doing business consulting for projects in the enterprise application development using web-oriented technologies such as J2EE, Web Services, ESB, TIBCO, PHP.

You may also like...