Any LXP file can be included within another LXP file, if the Apache server has read access to the document specified
in the src attribute. Any variables set in the including LXP document will be both
accessible, and modifiable, by the included LXP document.
To include an LXP file, open an LXP region, and use the following syntax where
lxpfile
is the name of the LXP file you wish to include:
<include src="
lxpfile
" />
Note: When an LXP file is included, it is parsed as if it had been directly called. Therefore, you must still use the
<lxp> tag to open an LXP region in the included LXP document before you are able
to use LXP tags within it.
Since the output of the included LXP document is embedded in place of the
<include> tag itself, no closing tag is necessary with this inclusion method. In
this case, the <include> tag should be an empty-element tag (i.e., with a trailing
slash). If the LXP file you are including does not have an extension ending in
.lxp
, you may force it
to be parsed by the LXP module by using the method="lxp" attribute.
Suppose that you have an LXP application that provides different content depending on the virtual host accessing the
site. Each virtual host's DocumentRoot could store just a single
index.lxp
file, configured to include the root LXP application from another directory. Example 13-21 demonstrates such a simple top-level file, which sets two protected LXP variables, and
includes the root LXP file.
Example 13-21. Including an LXP document
<lxp>
<setvar lxp.virtual_host="0" />
<setvar lxp.access_level="1" />
<include src="../application/index.lxp" />
</lxp>