|Kongregate Registration for Free Flash Games and Chat with solprovider|
Using the XpathDirectory Generator for Aggregating Multiple Files
This is about aggregating XML files from a directory and possibly subdirectories. This makes it possible to aggregate an entire publication into a single file.
Start by reading two pages from the official Cocoon documentation. The first defines the XpathDirectory Generator.
You also need to read about the Directory Generator, because the XpathDirectory Generator inherits many of the configuration options, and the documenter did not make the first page complete.
And now the reason this page exists. The XpathDirectory Generator works great, but the programmers forgot to make it usable by regular people.
DepthThere is no method to disable "depth". The default "1" returns a single directory. "0" returns nothing. I set it to "99"; the OS should break before hitting that limit.
Xpath ParameterThe xpath parameter does not understand namespaces. To return:
This makes the value very long, especially if you want more than one field. The field separator is the pipe '|'.
Using the ResultsThe XML returned is a mess. The XPath is included in every entry, when it should be in a confiuration section, and you probably do not want it at all. You will want an XSLT to turn the results into something usable before the usual XSLT to make the results displayable. The structure is:
The namespaces (that couldn't be configured in the last comment) will show in the results, so the example would match:
Make certain to copy the appropriate namespace headers to your XSLTs.
Getting the File PathWhen retrieving subdirectories, the results are even messier. In good XML fashion (and inherited from the Directory Generator), the directories are recursive entries. That is great if you want to display a tree of the files. The path of subdirectores is not stored in their entries, just the current directory name. That is bad if you want to merge the information and remember the path that generated each entry. The following stylesheet filters the files, adds the full path, and flattens the XML so each file is a first-level entry.