Solprovider Lenya Kongregate Registration for Free Flash Games and Chat with solprovider

Views: Setting Breakpoints in Pipelines

Lenya has the ability to break from any pipeline at any time and display it. This is incredibly useful for debugging.

NOTE: Cocoon Views do not work with Usecase XMAPs. I have no idea how Lenya managed to break them. You will need to force breakpoints using a different method.

Add this to your XMAP (Sitemap) after components and before resources and pipelines:
<map:views>
<map:view name="debug" from-label="debug">
<map:serialize type="xml"/>
</map:view>
</map:views>


Add the label property to a tag in your pipeline where you want to break. The choices are:
<map:generate label="debug">
<map:aggregate label="debug">
<map:transform label="debug">
<map:part label="debug">

The first three break immediately after the command with the results of that command. The map:part breaks and only returns the results of the map:part (because you would break the aggregate if you wanted more.)

To use it, add "?cocoon-view=debug" to your URL:
http://127.0.0.1:8888/default/live/index_en.html?cocoon-view=debug

I recommend adding label="xdebug" to each tag where you might want to break. Remove the "x" for the tag where you currently want to break, and put it back to continue to the next breakpoint.

You could add many labels with their own name, but to activate each breakpoint requires another map:view tag. That is useful if you want to switch between 2 or more breakpoints without editing your pipelines, but most of the time you will debug one tag in a pipeline, then continue with a later tag when this one displays the desired results.

Advanced

The map:view tag supports transformation and most other tags just like a pipeline:
<map:view name="debug" from-label="debug">
<map:transform src="xslt/mypage2xhtml.xsl"/>
<map:transform type="i18n">
<map:parameter name="locale" value="{page-envelope:document-language}"/>
</map:transform>
<map:serialize type="html"/>
</map:view>


map:view cannot include a generate or aggregate tag; the data must come from the pipeline.

You could use this to display alternate stylesheets for the same data, but Multiple Stylesheets is more maintainable since it does not require reproducing all the processing after the breakpoint. Most non-debugging uses of Views is better handled by adding Pipelines, and using Resources for code reuse.

Obsolete

There was a tag that allowed easy debugging by moving it. You could set the breakpoint in a pipeline with:
<map:label name="debug"/>

This command was so useful that it was deprecated! Lenya 1.2.2 will error on <map:label>.

Name

I believe breakpoints were called "Views" because they allowed "alternate views of the data". This is bad because too much software uses "View" to mean a dynamically generated collection of records matching a SELECT statement. From the name, I expected Views to allow easy aggregation of all XML (or other data) files in a directory (which would be incredible for developing a blog application!)

You could use Views to create functionality in your publication, but they seem better suited for debugging. They are like GOTOs, but with the jump hidden inside other tags. Like GOTOs, maintenance becomes much more difficult when they are used.

More information

The official documentation is at Cocoon Views. It offers additional information useful if you are developing your own Generator or Transformer.

<< NestingUsecase Sitemaps >>

Contact Solprovider
Paul Ercolino