morphis logo morphis | wax   
morphis manual
manual
 

Processing
   Dispatching
   Requesting
   Translating

Installation
   Requirements
   Instructions
   Config Properties

Dispatching
   Configuration
   Pre/Post Filters

Requestors
   URL Requesting
   Servlet Chaining
   Run-time Instructs
   Custom Requestors

Translators
   Non-Translator
   Custom Translators

SAX Translators
   XSLT Translation
   Custom SAX Filters

Requestors: Specifying Run-Time Processing Instructions

In many instances it may be more appropriate for the source document itself to determine how it should be processed. For example, a document may always be coupled with a particular stylesheet. Or, possibly, the HTTP Proxy Server knows how the document should be translated, or is able to determine certain processing parameters.

There are few places to define translation processing intructions. Following is a table showing where the instructions reside, and where they apply.

Applicability of Run-Time Processing Instructions

Location of Processing Instruction Applicability
dispatch.xml Everywhere
XML Processing Instruction

Any Requestor, only SAX Translator, only XML document parsing

HTTP Header HTTP Requestor, Servlet Chaining, any translator
Servlet Attributes Servlet Chaining only
  • dispatch.xml: As shown in the Dispatch Configuration section you may specify translation processing instructions in the dispatch.xml file itself. Since this file orginates all processing, you may use this method alone to specify instructions.

  • XML Processing Instructions: If the document being translated is using the SAX Translator and you are parsing an XML document, you may specify XML-style processing instructions in the document intself. The PI must occur directly after the <?xml ... ?> declaration. In the case of processing parameters, these values overwrite existing parameters. In the case of filters, these instructions will append to the end of any existing filter.

    For parameters, the the instructions must be in the format of:

    <?morphis-param name="..." value="..."?>
    <?morphis-param name="contenttype" value="text/html"?>


    You may also include specifications for SAX Translator filters by specifying (again, these are appended to any other processing which is specified in dispatch.xml. There is a current limitation of one parameter name/value pair per translate filter.

    <?morphis-filter type="translate" class="org.foo.MyFilter"?>

    ..or..

    <?morphis-filter type="translate" class="org.foo.MyFilter"
    name="param" value="param"?>


    You may specify XSLT processing along with the name of the XSL stylesheet with either of the following two processing instructions. The second example assumes you wish to perform XSLT processing with the supplied stylesheet.

    <?morphis-filter type="translate" class="org.morphis.translator.XSLTAdapter" name="stylesheet" value="foo.xsl"?>

    ..or..

    <?xml-stylesheet href="foo.xsl"?>


    Specifying multiple processing parameters will cause the stream to be processed multiple times. Therefore, the following will cause two XSLT processings to occur:

    <?xml-stylesheet href="process1.xsl"?>
    <?xml-stylesheet href="process2.xsl"?>


  • HTTP Header: When using the HTTP Proxy Requestor or Servlet Chaining, the originating data provider (server, Servlet, JSP, etc.) is capable of specifying translation processing instructions. These instructions are specified as HTTP headers. Since having multiple headers with the same name may be ambiguous to certain application or web servers, multiple values should be concatenated. Since headers are read before translation occurs, parameters set in HTTP headers should generally take less precedence over those specified in dispatch.xml.

    The following example shows how to specify a processing parameter in an HTTP header:

    morphis-param: name="..." value="..."


    Multiple parameters may be set like this:

    morphis-param: name="foo" value=bar" name="zoo" value="zar"


    Filters may be speicifed in a simliar fashion:

    morphis-filter: type="translate" class="org.foo.MyFilter"

    .. or..

    morphis-filter: type="translate" class="org.foo.Myfilter" type="translate" class="org.foo.AnotherFilter"


    And you may specify parameters to filters in this way:

    morphis-filter type="translate" class="org.morphis.translator.XSLTAdapter" name="stylesheet" value="foo.xsl"


    Again, multiple filters may appear in a row to specify multiple processing stages.

  • Servlet Attributes: If you are processing your document using Servlet Chaining, you may specify additional processing instructions by using Servlet attributes. Attributes take the same form as headers. In fact, using Servlet Chaining you may specify additional instructions as headers, too.
morphis SourceForge Logo