You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by Thorsten Scherler <th...@juntadeandalucia.es> on 2008/09/23 09:41:39 UTC

[AXIOM] Use case description: Forrest Dispatcher

Hi all, 

like Saliya ask I want to describe my use case and search for your
opinion.

Use case description: Forrest Dispatcher [2]
The idea of the dispatcher is to provide a template approach for
structuring a resulting document [1] and aggregate arbitrary data
sources. The underlying templates are called structurer [3] and can
configure multiple output formats. 

You can use two different tags in the structurer [4] that will influence
the resulting document. There are hooks that are the styling side of the
structurer, you can imitate arbitrary html skeleton with their help. 

On the other hand you have contracts that are basically providing the
actual data. Till now all contracts that we have are basic xsl
stylesheets the dispatcher invoke a transformation on them [5].

The result of this transformation will be in a envelope like data
structure:

<forrest:content xmlns:forrest="http://apache.org/forrest/templates/1.0">
  <forrest:part> Content going to the location defined by the
    structurer.</forrest:part>
  <forrest:part xpath="/html/head">
    <meta
      content=" Content going to a fixed location defined by the contract (here: /html/head)."
      name="Description" />
  </forrest:part>
</forrest:content>

The interesting part here is <forrest:part xpath="/html/head"/>. That will request 
that the content within the tag should be injection in the given xpath.

The structurer [4] has a similar attribute <structure type="html" hooksXpath="/html/body">.
The first forrest:part in above example does not provide a @xpath meaning it want to store 
the result in the hierarchical location which is determinate in the structure.

In our case the first content part will be stored in 
/html/body
and the second part in
/html/head

Meaning contracts can request to inject resulting data in arbitrary xpath location of the 
resulting document. 

The current active location has solved the problem by using DOM, but the code we used is a wee
bit complex and speed wise enhanceable. 

That let us to create a StAX based implementation http://svn.apache.org/repos/asf/forrest/trunk/whiteboard/dispatcher.

In this implementation the result of above transformation of contracts
is stored as XMLEvents in a list. Each xpath is then stored in a Map as
key of this list object [7] processContractResult(InputStream
resultStream). In the end of processing of the structure each list of
XMLEvents entries of the map is passed to a writer [7]
createResultStax(XMLEventWriter writer).

That works fine if you do have one main list of events but when you want
to inject in arbitrary location of the document that is not working fine
since it loose the overall hierarchical order (the OM).

This is the reason I am looking into AXIOM since I hope to solve the
problem of injection without using DOM.

salu2

[1]
http://svn.apache.org/repos/asf/forrest/trunk/whiteboard/dispatcher/docu/diagrams/dispatcher-overview-flow.png
[2]
http://forrest.apache.org/pluginDocs/plugins_0_80/org.apache.forrest.plugin.internal.dispatcher/
[3]
http://forrest.apache.org/pluginDocs/plugins_0_80/org.apache.forrest.plugin.internal.dispatcher/how/howto-dispatcher-structurer.html
[4]
http://svn.apache.org/repos/asf/forrest/trunk/whiteboard/dispatcher/testing/org/apache/forrest/dispatcher/master.structurer.xml
[5]
http://svn.apache.org/repos/asf/forrest/trunk/whiteboard/dispatcher/docu/diagrams/dispatcher-xsl-contract.png
[6]
http://svn.apache.org/repos/asf/forrest/trunk/whiteboard/dispatcher/testing/org/apache/forrest/dispatcher/master.contract.xml
[7]
http://svn.apache.org/repos/asf/forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions