You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by so...@gmail.com on 2005/04/21 03:29:07 UTC

Re: Sitemap issues (Explanation of generating Lenya webpages)

On 4/20/05, Rolando Isidoro <rl...@uninova.pt> wrote:
> Hi, I followed your tips and implemented a pipeline with nested matches in
> the file publication-sitemap.xmap like this:
> <map:pipeline>
>   <map:match pattern="live/people/*.html">
>         <map:aggregate element="cmsbody">
>           **
>         </map:aggregate>
>         <map:serialize type="html"/>
>         <map:match pattern="live/people/asg*.html">
>           <map:generate src="http://www.xmlhack.com/cdf.cdf"/>
>           <map:transform src="xslt/xmlhack.xsl"/>
>           <map:serialize type="html"/>
>         </map:match>
>   </map:match>
> </map:pipeline>
> 
> I'm having a hard time in getting the right lines to put in ** so that
> the menus, breadcrumbs and search bar appear correctly followed by the
> content under each specific person's document.
>
> I've copied some of those lines [from Lenya's pipeline for building the page], altered them to suite my needs but failed
> to come up with the result I'm looking for because of the differences
> existent in the pattern of the matches and its subsequent tokens. Can you
> give me some help? I've lost several hours around it and I think that I'm
> making some sort of confusion with this, that I've been unable to solve so
> far.
> Rolando

For a usable answer, skip to the bottom.

1. You should only have one serializer per section.  If you have
multiple serializers, they need to be in some form of if-else so only
one is used.  Only the final process should return "html"; all others
should return "xml".  The <map:serialize type="html"/> after the
aggregation should kill the processing (or at least return a mess.)


2. In my previous example, I demonstrated calling the aggregator with
hardcoded information that does not matter:
<map:part src="cocoon://navigation/{page-envelope:publication-id}/live/breadcrumb/index.xml"/>

2.a The publication name is required, but can be found without using
the match parameters.  (It could be hardcoded if you do not care about
code reuse.)
2.b The area is required, but can be hardcoded to "live".
2.c A target is required.  If there is an entry point in your sitemap
to be used for breadcrumbs, tabs, and menus, then replace index.xml
with it.  Otherwise use "/index.xml" so the navigation elements return
as if on the homepage.  Search can always be set to "/index.xml" since
it does not use the target.


3. It does not look like your matches integrate properly.  Follow the
usual pattern (I left out irrelevant transformations):
      <map:match pattern="**.html">
                 <map:generate
src="cocoon:/lenyabody-view/{page-envelope:publication-id}/{page-envelope:area}/{page-envelope:document-type}{page-envelope:document-url}"/>
                 <map:serialize type="html"/>
       </map:match>

Notice the {page-envelope:document-type}.  That is when Lenya checks
parameter-doctype.xmap to get a value.  Each numbered variable is set
to the * in the match pattern:
{1} = "view"
{2} = publication-id
{3} = area
{4} = document-type
{5} = document-url with first slash removed.
2, 3, and 4 could (or should) have been added to the code later rather
than passed as parameters.  Doing it in the match pattern
accmomplishes three things:
1. document-type requires some processing, so this calls that code once.
2. It allows shorter names in the src parameters.
3. It confuses everybody because they have to remember which number
refers to which variable.

      <map:match pattern="lenyabody-*/*/*/*/**">
        <map:aggregate element="cmsbody">
          <map:part src="cocoon://navigation/{2}/{3}/breadcrumb/{5}.xml"/>
          <map:part src="cocoon://navigation/{2}/{3}/tabs/{5}.xml"/>
          <map:part src="cocoon://navigation/{2}/{3}/menu/{5}.xml"/>
          <map:part src="cocoon://navigation/{2}/{3}/search/{5}.xml"/>
          <map:part
src="cocoon:/lenya-document-{1}/{3}/{4}/{page-envelope:document-path}"/>
        </map:aggregate>
        <map:transform src="xslt/page2xhtml-{4}.xsl"/>
        <map:serialize type="xml"/>
      </map:match>

Skip to the content, since the navigation pulls from other files.  The
parameters are:

      <map:match pattern="lenya-document-*/*/*/**.xml">
        <map:mount check-reload="true" reload-method="synchron"
src="doctypes.xmap" uri-prefix="lenya-document-"/>
      </map:match>

== doctypes.xmap
{1} = "view"
{2} = area
{3} = document-type
{4} = document=path with final ".xml" removed

      <map:match pattern="*/*/*/**.xml">
        <map:generate src="content/{2}/{4}.xml"/>
        <map:transform src="xslt/{3}2xhtml.xsl">
          <map:parameter name="rendertype" value="{1}"/>
          <map:parameter name="nodeid"
value="{page-envelope:document-node-id}"/>
          <map:parameter name="language"
value="{page-envelope:document-language}"/>
        </map:transform>
        <map:serialize type="xml"/>
      </map:match>

This pulls the XML from {pub}/content, and performs a transformation
xslt/{document-type}2xhtml.xsl.

You probably do not need to understand this, but here is how the
navigation XML is generated:
== global-sitemap.xmap
The navigation elements come from here, passing the parameters after
removing the first.
      <map:match pattern="navigation/**">
        <map:mount uri-prefix="navigation" src="lenya/navigation.xmap"
check-reload="true" reload-method="synchron"/>
      </map:match>

== navigation.xmap
{1} = publication-id
{2} = area
{3} = navigation element name
{4} = document-url with first slash and final ".xml" removed

    <!-- pattern: {pub-id}/{area}/{nav-element}/{url}.xml -->
    <map:match pattern="*/*/*/**.xml">
      <map:generate src="cocoon:/{1}/{2}/sitetree/{4}.xml"/>
      <map:call resource="fallback-transformation">
        <map:parameter name="publication-id" value="{1}"/>
        <map:parameter name="url" value="{4}"/>
        <map:parameter name="stylesheet" value="{3}"/>
      </map:call>
    </map:match>

The XML source comes from
pubs/{publication-id}/content/{area}/sitetree.xml, and is passed
through sitetree2nav.xsl:
{1} = publication-id
{2} = area
{3} = document-url with first slash and final ".xml" removed

    <map:match pattern="*/*/sitetree/**.xml">
      <map:generate src="pubs/{1}/content/{2}/sitetree.xml"/>
      <map:call resource="fallback-transformation">
        <map:parameter name="publication-id" value="{1}"/>
        <map:parameter name="url" value="{3}"/>
        <map:parameter name="stylesheet" value="sitetree2nav"/>
      </map:call>    
    </map:match>


*** How to use this to create your own pipeline ***

Your first decision is where Lenya should enter your code.  There are
two good possibilities for your goals:
1. Interrupt before <map:match pattern="**.html">
Add a match and write everything needed to create your page.
{1} = url before "/people/"
{2} = url between "people/" and ".html"
<map:match pattern="**/people/*.html">
      <map:aggregate element="cmsbody">
          <map:part
src="cocoon://navigation/{page-envelope:publication-id}/{page-envelope:area}/breadcrumb/index.xml"/>
          <map:part
src="cocoon://navigation/{page-envelope:publication-id}/{page-envelope:area}/tabs/index.xml"/>
          <map:part
src="cocoon://navigation/{page-envelope:publication-id}/{page-envelope:area}/menu/index.xml"/>
          <map:part
src="cocoon://navigation/{page-envelope:publication-id}/{page-envelope:area}/search/index.xml"/>
          <map:part src="cocoon:/people-{2}"/>
        </map:aggregate>
        <map:transform src="xslt/page2xhtml-people.xsl"/>
        <map:serialize type="xml"/>
      </map:match>
(You should copy all the code in <map:match pattern="lenyabody-*/*/*/*/**">.

       <map:match pattern="people-**">
         <map:generate src="http://www.xmlhack.com/cdf.cdf?{1}"/>
         <map:transform src="xslt/xmlhack.xsl"/>
         <map:serialize type="html"/>
       </map:match>
Notice I added the filename requested (without an extension) to the
querystring of the remote request.


2. Interrupt at getting the data.
2.a Set a new doctype in "parameter-doctype.xmap". This code must be
before <map:match pattern="*/**.html">:
      <map:match pattern="**/people/*.html">
        <map:generate type="serverpages"
src="../../config/parameters/default.xsp">
          <map:parameter name="value" value="people"/>
        </map:generate>
        <map:serialize type="xml"/>
      </map:match>

2.b Get the content from the remote source in "doctypes.xmap".  This
code must be before <map:match pattern="*/*/*/**.xml">:
{1} = "view"
{2} = area
{3} = document=path with final ".xml" removed
      <map:match pattern="*/*/people/**.xml">
        <map:generate src="http://www.xmlhack.com/cdf.cdf?{3}"/>
        <map:transform src="xslt/people2xhtml.xsl">
          <map:parameter name="rendertype" value="{1}"/>
          <map:parameter name="nodeid"
value="{page-envelope:document-node-id}"/>
          <map:parameter name="language"
value="{page-envelope:document-language}"/>
        </map:transform>
        <map:serialize type="xml"/>
      </map:match>
Notice I added the filename requested (without an extension) to the
querystring of the remote request.


2.c Use these filenames for your transformation:
xslt/people2xhtml.xsl  (Use whatever is specified in 2.b, but this is
the standard naming convention.)
xslt/page2xhtml-people.xsl


I recommend the second option.  It is much less code (less chance of
bugs), and takes advantage of Lenya's standards.

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org