Generator: GetConfigFile
Class name: | org.weborganic.bastille.psml.GetConfigFile |
---|---|
Version: | 0.7.5 - 25 October 2012 |
Library: | Bastille |
Cacheable: | Yes |
Generated: | 2012-12-21 |
Description
This generator returns the content of a PSML file using the specified path
parameter from the PSML config folder.
The config folder is the folder named ‘config’ under the PSML root folder.
The purpose of the config folder is to store all documents that don’t form part of the main content of the website and should not be viewed on their own. These include:
- The navigation (see Generator: GetNavigation).
- Headers and footers.
- Asides.
Files which can be viewed on their own generally go in the content folder; they can be retrieved with the Generator: GetContentFile generator.
Configuration
No configuration is required.
The root of the PSML folder can be configured using the global property bastille.psml.root
, which can be either an absolute path or a relative path from the global repository.
By default, the PSML root is set to “psml”, which usually corresponds to the /WEB-INF/psml
folder of your Web app.
Parameters
This generator requires a path
parameter. The path parameter must be a relative path from within the PSML config folder to a PSML file without the extension.
If the path resolves to a location outside the PSML folder, this generator wont read the file.
Returned XML
Like most PSML generators returning a PSML file, this generator wraps the content of the file with the <psml-file>
element.
The @base
attribute is the relative path from the PSML root to the folder. Since references (xrefs and image sources) in PSML are relative, this attribute can be used to construct the path to images or cross-referenced documents.
See the following:
<psml-file name="[file name]" base="[base path]" status="[status]"> <!-- PSML file content --> </psml-file>
Error handling
If the file cannot be found or read, this generator returns the following:
<psml-file name="[file name]" base="[base path]" status="not-found"> Unable to find file: [path] </psml-file>
The status of this generator is set to ‘NOT_FOUND’.
Usage
Following is the code to include in the services:
<generator class="org.weborganic.bastille.psml.GetConfigFile" ... > <parameter name="path" value="[path]"/> </generator>
Note that it is equivalent to:
<generator class="org.weborganic.bastille.psml.GetFile" ... > <parameter name="path" value="config/[path]"/> </generator>
Example: header
<generator class="org.weborganic.bastille.psml.GetConfigFile" name="header" target="header"> <parameter name="path" value="header"/> </generator>