From: Michael B. <mbe...@mb...> - 2006-02-12 16:42:30
|
David J Birnbaum wrote > is it > generally more efficient to: > > 1. Run separate queries to retrieve a bunch of little pieces and then > assemble them after retrieval, or > 2. Run a single query to retrieve whatever contains all of the pieces > and then use XSLT to pluck out only the parts I'm interested in? I'm not sure that's really the choice you face. > > For example, if I have a set of bibliographic records, each with many > fields, and I want to retrieve only the author and title fields from > each record, should I: > > 1. Find the number of bibliographic records and then iterate through > them, retrieving each author and each title separately, or > 2. Retrieve each entire record with a single XQuery and then use XSLT > to throw away everything except the author and title? You can, in one XQuery, retrieve (via a single XPath expression) a node sequence containing just the author and title nodes, then either return the entire sequence, or use a FLOWR construction to iterate over the nodes, wrapping them in whatever XML (or HTML) you choose. No XSLT (or multiple queries) needed. > In case it makes a difference, I've been developing my scripts along two > lines: > > 1. Plain ol' XQuery scripts that the user accesses through jetty on > port 8080, and > 2. Php scripts that the user accesses through an Apache httpd server > on port 80, which then makes calls to eXist through xmlrpc (using > the php api available on the eXist cvs site). I think the PHP route is overkill for what you describe. I would use PHP (or other mid-tier scripting) in this way only if I had to munge either the user input or the returned data in ways that were either difficult or (currently) inefficient in eXist's implementation of XQuery. As I said in an earlier post, if all you want to to is redirect from port 80 to your eXist server, then reverse proxying is a much more lightweight way to do it. Lightweight both in terms of configuration and scripting your end (once you have Apache reverse proxying for you, you can forget it's there and proceed as though you or your users were addressing the eXist server directly), and in terms of server resources if you want at any stage to cater for a number of concurrent users (each of whom, if you use PHP and xmlrpc will be spawning and running a big chunk of code just to get to and from eXist). Michael Beddow |