Contentwork

The tool Contentwork is part of Patchwork and allows you to define so called content definitions and assign it to different layouts within your Patchwork configuration.

This approach is very useful if you want to seperate the content from the design but with as less effort as even possible. Let's assume you would like to read a XML document news.xml containing news articles for the news section of your website. What could you do in order to load the news and then display them on your website?

  • You could write a XSLT stylesheet that transforms the news.xml into XHTML.
  • You could write controller logic (using an Action or a Flowscript for example) in which you will parse the xml document.

The first approach is a relatively huge effort for such a little thing and introduces XSLT for producing a "design oriented document" like XHTML. This means normally a Web Designer will first create the website using its favourite web design software or as plain HTML. After that the dynamic areas of the website must be implemented. Using XSLT here , the templates get embedded and splitted-up into the XSLT-Stylesheet(s). This makes it nuch more harder to read and maintain such "design" templates. Using a template language like FreeMarker, Velocity or Cocoon's JXTemplate, this is not the case, because you can leave most of the templates content untouched and the web designer is still able to read and understand the templates even with dynamic areas.

The second approach do not help you in achieving a clean and maintainable architecture because it brings the XML parsing process into your Controller.

With Contentwork, the only thing you have to do is to tell your layout in your Patchwork configuration which XML content to provide and that's it. After that, you can access this XML content from within your template like you would do with JavaBeans.

And note, XSLT can be used here for example to prepare your content data. Since the xml Content Provider supports the cocoon:/ protocol, you can refer to a Cocoon pipeline and then load the result of this pipeline into your template, without merging documented oriented XML and data oriented XML using an XSLT-Stylesheet.

Please also see the FAQ about Why not using XSLT for merging data XML and template?.