I recently started learning about XSLT as a template engine (for PHP, if that matter), and I've been wondering: how are you supposed to store the data?
- XML - seems to be inefficient in terms of size and maybe performance (because of storing in DB or file
- raw data - seems to chew up system resources, because of the requirement to convert it to XML before sending it to the XSLT engine. but much smaller in terms of size.
So my question is: what should I be using (or what are you using - XML, raw data, other option I'm not aware of)?
EDIT: 1. in "raw data" i mean store strings (in DB, for example) against storing wh开发者_开发百科ole XML documents
2. the debate is about a view in a MVC pattern which is supposed to translate data into HTML/RSS/JSON/XMLFor many applications storing XML documents as files in filestore gives perfectly adequate performance.
Equally, for some applications storing XML documents as blobs in a relational database works quite well enough.
But if you really want to maximize performance, you're probably best off using an XML database such as eXist or MarkLogic.
You seem to be falling into the trap of being anxious about performance without having clear metrics on what performance your system has to deliver.
It depends on how you're accessing data. If you want to access (or even modify) parts of your data separately, you're probably better off with storing it in raw form, indexes are easier to create that way.
If the rest of the system treats your data as a black box, you'll probably want to store your data in XML format.
A third alternative is to use an XML-aware (or even native XML) storage, which will allow you to build indexes and do efficient queries on parts of your XML data.
But these are just general guidelines, a decision has to be made on a case-by-case basis.
Without more information it is hard to give an answer -- what kind of data, how it is to be accessed? Form follows function here, too.
Relational database and XML have very different models (relational vs hierarchic), and main difference is not necessarily performance (both can be efficient or inefficient) but usage and access patterns. And I am not quire sure what "raw" data would mean -- maybe platform default serialization?
One minor on XML storage: XML compresses nicely, so when storing sizable XML documents, on-the-fly compression (with gzip etc) makes sense. Compression ratios can be high; I had 30-to-1 compression for log files that were written as xml.
精彩评论