cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giacomo Pati <Giacomo.P...@pwr.ch>
Subject Re: Do C1 & C2 coexist?
Date Mon, 28 Aug 2000 21:51:13 GMT
Jeremy Quinn wrote:
> 
> At 03:33 -0700 28/08/00, Giacomo Pati wrote:
> >> BTW. Do PIs still work in C2?
> >
> >PIs? You mean the special cocoon PIs? I don't think so. What C1 does
> >with PIs is dont in the C2 sitemap now.
> >
> >> Is this how you produce dynamic pipelines at runtime like C1 or is
> >> this
> >> different?
> >
> >Definitely different. It's all done in the sitemap. Have a look at it.
> 
> So how do you do things like this, ( that I find very handy :)
> 
>                 <xsp:pi target="xml-stylesheet">href="page-<request:get-parameter
> name="as" default="html"/>.xsl" type="text/xsl"</xsp:pi>
> 
> to switch between two stylesheets,
> 
>         page.xml?as=xml
>         page.xml?as=html

if you have a special "as" selector do it with this pipeline snippet:

    <map:match type="uri" pattern="page">
      <map:generate type="file" src="page.xml"/>
      <map:select type="as-selector">
        <map:when test="xml">
          <map:transform type="xslt" src="page-xml.xsl"/>
        </map:when>
        <map:otherwise>
          <map:transform type="xslt" src="page-html.xsl"/>
        </map:otherwise>
      </map:select>
      <map:serialize type="html"/>
    </map:match>

or if you have a special "as" matcher which returns the value of the as
parameter (including defaults) do it with this pipeline snippet:

    <map:match type="uri" pattern="page">
      <map:generate type="file" src="page.xml"/>
      <map:match type="as-matcher" pattern="unused">
        <map:transform type="xslt" src="page-{1}.xsl"/>
      </map:match>
      <map:serialize type="html"/>
    </map:match>

or use a view:

    <map:generator name="file" src="org.apache...FileGenerator"
label="content"/>
    ...
    <map:view name="content" generate-from="content">
      <map:serialize type="xml"/>
    </map:view>
    ...
    <map:match type="uri" pattern="page">
      <map:label type="content>
        <map:generate type="file" src="page.xml"/>
      </map:label>
      <map:transform type="xslt" src="page-{1}.xsl"/>
      <map:serialize type="html"/>
    </map:match>

    and use a URL like this

        page?cocoon-view=content

    to activate the "content" view

When I get the "default view behaviour" working not even the <map:label>
in the last snipped around the <map:generator/> is needed. All requests
which assemble a pipeline using the generator of type "file" (because of
the label="content" attribute) can be requested a "content" view.

Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch

Mime
View raw message