More sitemap spelunking: creating a new document

Continuing to learn by tailing logs, Day Two.

NB: The numbers after the colon in filenames refer to the line number.

Let's create a new page in the tutorial section of the default site.

{{{http://localhost:8080/lenya/default/authoring/tutorial.html?lenya.usecase=create \

What we're asking Lenya to do is create a new page, whose content is in XHTML, within the tutorial area of the default site.

"Matcher 'usecase' matched prepared pattern 'create' at webapps/lenya/sitemap.xmap:703:52"

So far, we've run across the wildcard matcher, we've not seen usecase before.

The documentation for the usecase matcher is in http://localhost:8080/lenya/docs-new/docs/concepts/usecases.html.

Looking at webapps/lenya/sitemap.xmap:703:52:

{{{<map:match type="usecase" pattern="create">


This directs Lenya to mount the usecase.xmap.

But where's the usecase matcher defined? It's in webapps/lenya/sitemap.xmap:279.

{{{<map:matcher name="usecase" logger="sitemap.matcher.usecase"


So all they've done here is define a ApacheCocoon:WildcardRequestParameterMatcher that looks for the parameter lenya.usecase in the request, and flags a request as a match if the parameter is present.

So continue to webapps/lenya/usecase.xmap since "Matcher 'wildcard' matched prepared pattern '*/*/**' at webapps/lenya/lenya/usecase.xmap:119:33"

That's the start of a group of usecase matches, however none of them agree with the lenya.usecase parameter create.

It's worth pointing out that you can nest map:match elements inside map:match elements.

So we go on to another URI pattern match.

"Matcher 'wildcard' matched prepared pattern '*/*/**' at webapps/lenya/lenya/usecase.xmap:210:33"

Again, there's no match inside the map:match, so we continue.

"Matcher 'wildcard' matched prepared pattern '*/*/**' at webapps/lenya/lenya/usecase.xmap:255:35"

Ah, now we see an immediate match inside this pipeline:

"Matcher 'usecase' matched prepared pattern 'create' at webapps/lenya/lenya/usecase.xmap:257:46"

{{{<!-- Create --> <map:pipeline>


How did Lenya know to look for a match with create, because the WildCardParameterRequest matcher assigned the value of lenya.usecase into a parameter used by the mounted sitemap.

Thus, we learn that one can pass parameters to matchers that are mounted within a sitemap: a useful thing to know.

Within <map:match type="usecase" pattern="create">, Lenya looks for a match with the request parameter lenya.step. The step matcher is another instance of the ApacheCocoon:WildCardRequestParameterMatcher.

The match is with showscreen:

{{{<map:match type="step" pattern="showscreen">


A Resource is just a reusable pipeline. The usecase-create resource is defined at the top of usecase.xmap.

Note also that we define a parameter to pass along, publication-id. It's set to default.

A detour into sitemap parameters and nesting is worthwhile.

When we entered the sitemap, the first match was with the usecase matcher which set the usecase parameter to create.

Then we matched the wildcard pattern */*/** which set parameters for the pieces of the URI.

Then we matched the step matcher with showscreen.

At that point, we had three levels of parameters. You'll find these defined in the log as:

{{{PARAM: '0' VALUE: 'showscreen' LEVEL 2 PARAM: '../0' VALUE: 'create' LEVEL 1 PARAM: '../../3' VALUE: 'tutorial.html' PARAM: '../../2' VALUE: 'authoring' PARAM: '../../0' VALUE: 'default/authoring/tutorial.html' PARAM: '../../1' VALUE: 'default'}}}

Each new match pushes the stack of parameter groups down a level. So to recall parameters matched earlier, we use the ../ notation.

There's more on this buisiness in the page on ApacheCocoon:SitemapVariableSubstitution. Read it.

Okay, back to the usecase-create resource:

{{{<map:resource name="usecase-create">

There is one, so it executes generating the XML for the page which asks for the page's id (for the URI) and the name (for the sitemap and navigation).

Then it's transformed with the appropriate XSLT and the form is delivered to the browser.

OverviewSitemapCreatePage (last edited 2009-09-20 23:27:29 by localhost)