Chapter 2. Technologies in XML 51
Matchers and selectors: conditional processing
Conditional statements are part of any programming language. Output can be
dependent on many factors, such as the users’ browser, request parameters, or
operating system.
Matchers are the equivalent of If statements. If a condition is true, then a section
of a pipeline is processed, or otherwise is passed by.
A selector is used when there are few options available, and it is similar to an
If-then-else statement. These are used to create conditional sections in the
pipeline, while matchers are used to test if a particular pipeline is to be
processed.
Figure 2-3 Cocoon components
Sitemap
The Cocoon sitemap fulfills two functions:
Components (matchers, generators, serializers, transformers, etc.) are
declared here before being used in pipelines.
Where pipelines are declared using the declared components.
It consists of configuration data for the Cocoon engine.
Example 2-14 Sample sitemap for Cocoon
<map:match pattern=”airline.html””>
<map:generate src=”docs/flight_data.xml”/>
<map:transform src=stylesheets/page/airline.xsl”/>
<map:serialize type=”html”/>
</map:match>
File Generator
File Serializer
File Transformer
SAX
SAX
request
reponse
HTML
XSL StyleSheet HTML, PDF, etc