Views

Views are means of interrupting the normal pipeline flow under the control of the user via the quesry string. It is similar to that of Cocoon but not quite so extensive. However even in its simple form it is a useful debugging aid. Take a typical example:

<map:views> <map:view name="raw" from-label="raw-content"> <map:transform src="context://resources/transforms/xml2xhtml.xsl"/> <map:serialize/> </map:view> </map:views>

The view is accessed by the name attribute and the label used in the actual pipeline is defined by the label attribute. ote that not components can be used in view pipelines; only call, transform and serialize. A typical pipe that uses this could be:

<map:match pattern="**.html"> <map:aggregate element="root" label="raw-content"> <map:part src="cocoon:/headings.xml" element="headings" strip-root="true"/> <map:part src="cocoon:/menus.xml" element="menus" strip-root="true"/> <map:part src="cocoon:/newsArticles.xml" element="news-articles" strip-root="true"/> <map:part src="cocoon:/{1}.xml" element="content" strip-root="true"/> </map:aggregate> <map:transform src="context://resources/transforms/page2html.xsl"> <map:parameter name="page" value="{1}"/> </map:transform> <map:transform src="context://resources/transforms/stripNamespaces.xsl"/> <map:serialize type="html"/> </map:match>

If the user puts in the URL, http://hostname/index.html?paloose-view=raw, the view pipeline named raw will be run after the aggregator is run in the normal pipeline, using the label raw-content. In this case the transform "xml2xhtml.xsl" (an XML pretty-printer) will be run on the output of the aggregator.

The only pipeline elements that can be labelled for views are aggregate, generate and transform.

Copyright 2006 – 2011 Hugh Field-Richards. All Rights Reserved.