About this page
Here is some additional information about using logicsheets in logicsheets that can make a critical difference in whether an application functions correctly or not. I believe it should be added to the official Cocoon docs at http://cocoon.apache.org/2.1/userdocs/xsp/logicsheet.html#Logicsheets+Using+Logicsheets. My source for this info is Alfred Nathaniel.
Additions and corrections are welcome. [LarsHuttar]
Application Order of Logicsheets
According to Alfred, when two or more builtin logicsheets are used in an XSP page, "the order [in which they get applied] is not defined since it is derived from the namespace declaration on the xsp:page root element." (See http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=112349070725456) However if one logicsheet is meant to produce XML that is to be transformed by another, the order of application must be well-defined. Otherwise you may get a situation where an application works sometimes, or even most of the time, but can fail at unpredictable moments.
To solve this problem, you can either put processing instruction <?xsp-logicsheet href="path/to/logicsheetA.xsl"?> before <xsp:page>, or add element <xsp:logicsheet location="path/to/logicsheetA.xsl"/> as the first child of <xsp:page>, where logicsheetA is the logicsheet that must run first (because it produces output to be processed by another logicsheet). This tells the logicsheet processor to add logicsheetA before adding any logcisheets referenced by xml namespace declarations. Examples for href and location attributes:
- location="path/to/logicsheetA.xsl" (a file path relative to current sitemap, or absolute)
- location="context://path/to/logicsheetA.xsl" (a file path relative to webapp directory)
- location="cocoon:/path/to/logicsheetA.xsl" (a pipeline URL relative to current sitemap)
- location="cocoon://path/to/logicsheetA.xsl" (a pipeline URL relative to root sitemap)
NB The xsp:logicsheet magic happens in o.a.c.components.language.markup.CocoonMarkupLanguage.CocoonTransformerChainBuilderFilter.
PS AbstractMarkupLanguage.addLogicsheetsToGenerator is responsible for logicsheet application order, I have not seen cases when it's not working -- Vadim
PPS See http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=112327051428249 for a description of such a case. If you would like more information please let me know. -- Lars