Project Forrest has retired. For details please refer to its Attic page.
SourceTypeAction (content aware pipelines) (v0.8)
Apache Software Foundation > Apache Forrest
Font size:      

SourceTypeAction (content aware pipelines)

This is documentation for past version v0.8 (More)


SourceTypeAction assigns a "type" (a string) to an XML file. This is done based on information occuring in the header of the XML file, up to the document (root) element. This type is then returned to the sitemap as a variable with the name 'sourcetype'. If no matching sourcetype could be be found, null is returned and thus the contents of the action element will not be executed.

SourceTypeAction works by pull-parsing the document and collecting information such as the Public Id, the processing instructions, the document element local name and namespace, and the xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes. This information is then compared with the rules described in the configuration of the SourceTypeAction.


The action should be declared and configured in the map:actions section of your sitemap. Example:

<map:sitemap xmlns:map="">
   <map:action name="sourcetype"
    <sourcetype name="download-v1.0">
        public-id="-//Acme//DTD Download Documentation V1.0//EN" />


There are other examples in main/webapp/forrest.xmap

Each sourcetype-tag declares a source type. Inside the sourcetype-tag a number of rules can be defined, described below. The sourcetypes will be checked in the same order as they are defined in the configuration, the first sourcetype of which all rules match will be used.

These are the available rules:

This rule checks the public ID. It takes one attribute public-id.
This rule checks the local name and/or namespace of the document element. These are specified with the attributes local-name and namespace. At least one of these two is required.
This rule checks a processing instruction. It can take two attributes: target and data. The target attribute is always required, the data attribute is optional.
This rule checks the value of the xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes on the document element. These are specified with the attributes schema-location and no-namespace-schema-location.

Perhaps you need other methods. Please enhance the source at main/java/org/apache/forrest/sourcetype


The source of which the sourcetype must be defined must be specified using the 'src' attribute on the map:act element.

<map:act type="sourcetype" src="{1}">

See a real-life example in the advanced section of the Using Forrest document.