WebReference.com - Part 3 of Chapter 10 from Professional PHP4 XML, from Wrox Press Ltd (7/7)
Professional PHP4 XML, Chapter 10: Putting It Together
Other Querying Alternatives
There are other querying alternatives for XML such as XQL and XQuery. We didn't cover them in this chapter since there isn't a PHP implementation of these alternatives. As they evolve and become stable we may find PHP extensions that support them.
Chapter 14 has a short introduction to XQuery. The specification is available at http://www.w3.org/TR/xquery/.
Querying an XML document is the problem where more solutions can be applied - XQL, XQuery, XSLT, XPath, DOM, SAX, and others can be used to query a document. So it's useful to have a query class abstracting queries. Also, it is almost always good to separate what the application needs from how it is done.
Caching Strikes Back
As with transformations, we might cache query results to reuse the result if the same query is applied to an unchanged document. The same considerations we made about caching transformations apply here.
Choosing a Querying Strategy
With so many options, choosing a querying strategy can sometimes be hard. We recommend the following strategy:
- If the documents are really huge then use SAX.
- If there are medium-sized documents then try using XPath. If performance is not satisfactory, or the query can't be solved, use XSLT.
Created: August 26, 2002
Revised: August 26, 2002