Matchers are a core component of Cocoon. These powerful sitemap
components allow Cocoon to associate a pure
"virtual" URI space to a given set of instructions that describe
how to generate, transform and present the requested resource(s) to
the client.
Cocoon is driven by the client request. A request typically
contains a URI, some parameters, cookies, and much more. The
request, along with the Cocoon environment, is the entry
point to decide what will be the sitemap instructions to be
used. The mechanism to decide what will be the instruction
driving the Cocoon process for a given request
is based on matching a request element against a pattern given
as a matcher's parameter. If the match operation is successful
processing starts.
As an example, consider the following sitemap snippet:
 |  |  |
 |
<map:match pattern="body-faq.xml">
<map:generate src="xdocs/faq.xml"/>
<map:transform src="stylesheets/faq2document.xsl"/>
<map:transform src="stylesheets/document2html.xsl"/>
<map:serialize/>
</map:match>
<map:match pattern="body-**.xml">
<map:generate src="xdocs/{1}.xml"/>
<map:transform src="stylesheets/document2html.xsl"/>
<map:serialize/>
</map:match>
|  |
 |  |  |
Here the two sitemap entries are mapped to different virtual URIs using
the default matcher (based on a wildcard intepretation of the request
URI) in a different way: the first one
uses an exact match ("body-faq.xml"), meaning that only a Request URI
that exactly matches the string will result in a successful match. The
second one uses a wildcard pattern, meaning that every request
starting with "body-" and ending with ".xml" will satisfy the matcher's
requirement: thus requesting a resource such as "book-cocoon.xml"
would turn out in the sitemap matching the request and starting
the second pipeline.