Berlioz output
Berlioz produces two types of output:
Raw XML output | XML directly produced by Berlioz as a result of invoking the generators |
---|---|
Transformed output | Raw XML output that has been transformed for a particular output type |
Raw XML output
Whenever a request is made, Berlioz always produces a response by:
- Assembling the XML data produced by the generators.
- Including a header with various metadata about the request.
The XML response follows the structure below:
<root> <!-- Only one header, always first --> <header> ... </header> <!-- for each generator for the service --> <content generator=[class] name="[name]" target="[]" status="[]"> ... </content> </root>
XML header
The XML header returns information about the request and how Berlioz processed it. It is consistent and follows the structure below:
<header> <group>[service-group]</group> <service>[service-id]</service> <path-info>[path-info]</path-info> <context-path>[context-path]</context-path> <host>[host]</host> <port>[port]</port> <url>[request-url]</url> <query-string>[query-string]</query-string> <http-parameters> <!-- for each HTTP parameter --> <parameter name="[parameter-name]">[parameter-value]</parameter> </http-parameters> <uri-parameters> <!-- for each URI parameter --> <parameter name="[parameter-name]">[parameter-value]</parameter> </uri-parameters> <berlioz version="[berlioz-version]"/> </header>
service-group | The name of the group the service is part of |
---|---|
service-id | The ID of the service corresponding to the request |
path-info | The Berlioz path information (normally corresponds to the * in the <url-pattern> in the Web descriptor |
context-path | The context path of the application (may be empty) |
host | The host of the application server |
port | The port of the application server |
request-url | The request URL (without query string) |
query-string | The query string (part after the ? as defined in HTTP spec) |
parameter-name | The name of the HTTP or URI parameter |
parameter-value | The value of the HTTP or URI parameter |
berlioz-version | The version of Berlioz library in use |
XML content
Each generator used by the service that processed the request is wrapped in the following XML:
<content generator=[generator-class] name="[name]" target="[target]" status="[status]"> <!-- The actual content depends on the generator --> </content>
generator-class | The full class name of the generator invoked by the service |
---|---|
name | The name given to this generator content as defined in the services.xml configuration file |
target | The target for this generator content as defined in theservices.xml configuration file |
status | Indicates the status of the generator request; ‘ok’ if the generator could process the request without error; ‘error’ otherwise |
The actual XML content inside the <content>
element is specific to each generator. Look at the generators API for details.
Transformed output
Generally, Berlioz serves HTML or another output such as RSS, ICAL, etc.
The Berlioz servlet uses the style sheet as defined in the Web descriptor ( /WEB-INF/web.xml
) to transform the raw XML into the needed output.
By convention, the style sheet used by Berlioz is called global.xsl
.
Specifying the output type
The output type is specified in the XSLT style sheet using the <xsl:output>
element.
The Berlioz servlet uses the attributes in this element to produce the correct HTTP headers.
For example, to produce an HTML 4 output:
<xsl:output method="html" encoding="utf-8" indent="yes" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" undeclare-prefixes="no"/>
Or to produce a different XML:
<xsl:output method="xml" encoding="utf-8" indent="yes" media-type="application/xml" />