Java API
The complete API documentation is available here:
http://pageseeder.org/apidocs/berlioz/latest/index.html
Generators
Berlioz generates content from implementations of a ContentGenerator .
void process(ContentRequest req, XMLWriter xml) throws BerliozException, IOException;
A content generator is a simple class which must produce XML content based on a ContentRequest using an XMLWriter .
ContentRequest
A content request is a simple wrapper around an HTTPServletRequest
. Its most common use is to retrieve the parameters and attributes sent with the request as HTTP parameter or URI parameters and set the status of the content.
XMLWriter
The XML Writer provides methods to write XML simply escaping characters automatically.
For example:
xml.openElement("heading"); xml.attribute("level", "2"); xml.writeText("Hello World"); xml.closeElement();
Will produce the following XML:
<heading level="2">Hello World</heading>
"Hello World" generator
A simple example, printing the "message" parameter, defaulting on "Hello World if it isn't specified.
import org.weborganic.berlioz.content.ContentGenerator; import org.weborganic.berlioz.content.ContentRequest; import com.topologi.diffx.xml.XMLWriter; public class HelloWorld implements ContentGenerator { @Override public void process(ContentRequest req, XMLWriter xml) throws IOException { // Get parameter String hello = req.getParameter("message", "Hello World"); // XML xml.openElement("message"); xml.openElement(hello); xml.closeElement(); } }
Created on , last edited on