File generators read an XML file and present it to the pipeline for processing. They are always the first item of a pipeline (except for an aggregator that implies a generator). So a typical use of FileGenerator would be:

<map:generators default="file"> <map:generator name="file" src="resource://lib/generation/FileGenerator"/> ... </map:generators> <map:pipelines> <map:pipeline> <map:match pattern="downloads.xml"> <map:generate src="context://content/downloads.xml"/> ... </map:match> </map:pipeline> </map:pipelines>


The above code injects the file content/download.xml in the main site directory (context) into the pipeline. See also, PXTemplateGenerator.


In versions after 1.3.4 implicit entities defined by ISOlat1, ISOpub and ISOnum are translated into their numerical form. The EntityTransformer now only handles explicitly declared entities within a DOCTYPE statement within the XML file.

Caching Support (available after Version 1.3.0)

The FileGenerator component supports caching of the data within the pipeline. The input file is normally checked for being well-formed (no schema validation) but caching the data stores the XML after this process. As a result very little time is saved except on very large XML source files.


Note that if you have an XML file that includes other files (via xinclude), the generator caching will not detect that these other XML files have been modified. If you modify them it is important to clear out the caching to let the cache files to be rebuilt.

Enabling caching is done globally and locally. To turn on caching for all FileGenerators there is an attribute cachable that should be set to true (true/yes/1). So setting the global flag would be (default is false):

<map:generators default="file"> <map:generator name="file" src="resource://lib/generation/FileGenerator" cachable="yes"/> </map:generators>

This can be overriden by using the same attribute when the pipeline component is used:

<map:match pattern="*.xml"> <map:generate src="context://content/{1}.xml" label="xml-content" cachable="no"/> <map:serialize/> </map:match>

The above would turn off the caching for just this instance in the pipeline. It is also possible to change the action of the cache via the query string by using the request parameters. The following would control the generator instance by including the query string "?cachable=1" or "?cachable=0"

<map:generators default="file"> <map:generator name="file" src="resource://lib/generation/FileGenerator" cachable="no"> <map:use-request-parameters>true</map:use-request-parameters> </map:generator> </map:generators> ... <map:match pattern="index.xml"> <map:generate src="context://content/index.xml" label="index-xml" cachable="{request-param:cachable}"/> <map:serialize type="xml"/> </map:match>
Copyright 2006 – 2017 Hugh Field-Richards. All Rights Reserved.