XSP is a dynamic markup language like JSP (Java Server Pages) or ASP (Active Server Pages) that providing code embedding directives. But far more powerfull. It is tightly integrated to Cocoon.
An XSP document is a XML document with special XSPSyntax. A XSP document can be used as the starting point of a Pipeline. The XSP is processed by a special Cocoon Generator called ServerPagesGenerator.
The XSP processor of the ServerPagesGenerator converts the XSP document into a source program for a particular target processing language. Currently you can use XSP to generate source programs in Java, Javascript and Python.
Upon execution of the generated program, the resulting XML document described by the original XSP document will be generated, interspersed with dynamic content generated by the code extracted from the XSP tag directives.
There are 3 roles here:
- A Markup Language Processor -- turns XSP into source code for a given language.
- A Programming Language Processor -- compiles, loads and executes code generated by the above.
- A Program Generator -- co-ordinates the activity between the other two roles, caches results.
Shortly, an XSP document (XSP page) is used by the ServerPagesGenerator to create a XML document.
The image below shows in detail the process the XSP Compile Pipeline in pink:
The Generator reads XSP page and then turns it into target source code (for example java code) using XSLT transformations.
- Compile the generated code and
- Invokes the compiled code.
Note: "while XSP provides an abstraction for the different aspects of a page, i.e. the logic, expression, etc. The contents of these are still language specific. So essentially they only provide hooks to allow these to be generated easily. Not a pure language abstraction."
Using XSP
All XSP pages must be processed by a special Generator called the ServerPagesGenerator. Here is an example of how to configure it in your Sitemap:[[BR]]
{{{<map:generator label="content,data" logger="sitemap.generator.serverpages" name="serverpages"pool-grow="2" pool-max="32" pool-min="4" src="org.apache.cocoon.generation.ServerPagesGenerator"/>}}}
- Check the basic XSPSyntax.
You can use the the BuiltInLogicsheets that are already in Cocoon
The generated source code of your XSP pages will be placed placed in:
$CATALINA_HOME/work/localhost/web-app-name/cocoon-files/org/apache/cocoon/www
with the base below that depending on the directory path under $COCOON_HOME. Classes are renamed from XXX.xsp to XXX_xsp.java. Test Added by Yogesh