Differences between revisions 10 and 11
Revision 10 as of 2005-05-15 16:07:09
Size: 6760
Comment:
Revision 11 as of 2009-09-20 23:27:29
Size: 6739
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
The documentation for the usecase matcher is in [http://localhost:8080/lenya/docs-new/docs/concepts/usecases.html]. The documentation for the usecase matcher is in [[http://localhost:8080/lenya/docs-new/docs/concepts/usecases.html]].
Line 38: Line 38:
So all they've done here is define a wiki: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 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.
Line 92: Line 92:
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 wiki:ApacheCocoon:WildCardRequestParameterMatcher. 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.
Line 102: Line 102:
A [wiki:ApacheCocoon:Resources Resource] is just a reusable pipeline. The {{{usecase-create}}} resource is defined at the top of {{{usecase.xmap}}}. A [[ApacheCocoon:Resources|Resource]] is just a reusable pipeline. The {{{usecase-create}}} resource is defined at the top of {{{usecase.xmap}}}.
Line 132: Line 132:
There's more on this buisiness in the page on wiki:ApacheCocoon:SitemapVariableSubstitution. Read it. There's more on this buisiness in the page on ApacheCocoon:SitemapVariableSubstitution. Read it.
Line 152: Line 152:
 First we look to see if there's an XSP page associated with the publication. That's using the wiki:ApacheCocoon:ResourceExistsAction.  First we look to see if there's an XSP page associated with the publication. That's using the ApacheCocoon:ResourceExistsAction.

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 \

  • &lenya.step=showscreen&doctype=xhtml}}}

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">

  • <map:mount uri-prefix=""

    • src="lenya/usecase.xmap" check-reload="true"

      reload-method="synchron"/>

</map:match>}}}

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"

</map:matcher>}}}

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>

  • <!-- {publication-id}/{area}/{uri}--> <map:match pattern="*/*/**">

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

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

        • <map:call resource="usecase-create">

          • <map:parameter name="publication-id" value="{../../1}"/>

          </map:call>

        </map:match>

        <map:match type="step" pattern="create">

        • <map:act type="default-create">

          • <!-- if the action suceeds it returns the referer and we --> <!-- simply redirect to it. --> <map:redirect-to uri="{request:requestURI}"/>

          </map:act> <!-- otherwise the action could not validate some of the --> <!-- input and we present the upload form again --> <map:call resource="usecase-create">

          • <map:parameter name="publication-id" value="{../../1}"/>

          </map:call>

      • </map:match>

    • </map:match>

    </map:match>

</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">

  • <map:call resource="usecase-create">

    • <map:parameter name="publication-id" value="{../../1}"/>

    </map:call>

</map:match>}}}

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.

  • 0 -> default/authoring/tutorial.html

  • 1 -> default

  • 2 -> authoring

  • 3 -> tutorial.html

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">

  • <!-- use publication-specific schema if available --> <map:act type="resource-exists"

    • src="pubs/{publication-id}/content/authoring/create.xsp"> <map:generate type="serverpages"

      • src="pubs/{../publication-id}/content/authoring/create.xsp"/>

      <map:transform src="pubs/{../publication-id}/xslt/authoring/create.xsl"/> <map:serialize />

    </map:act>

    <!-- otherwise use default schema --> <map:generate type="serverpages" src="content/authoring/create.xsp"/>

    • <map:transform src="xslt/authoring/create.xsl"/>

    <map:serialize />

  • </map:resource>}}}

    First we look to see if there's an XSP page associated with the publication. That's using the ApacheCocoon:ResourceExistsAction.

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)