Jeremias Maerki <[EMAIL PROTECTED]> wrote:
> By the way: What's the current agreement whether to use Avalon or not? I
> mean, we're already using LogKit (which is cool).

No, it's not cool unless done properly. I don't think users
who want only pure FO processing should be forced to use
another heavyweigth framework and logkit.

I rather imagine something like the following layered
architecture:

1. FOP core. Processes XML, either as SAX event stream by
 supplying a content handler or by utilising the interface
 javax.xml.transform.Source, into a renderer specific result
 (probably a java.io.OutputStream, could even apply to a voice
 renderer :-)
 Do not rely on any hardcoded external files. Get configuration
 via a java.util.Properties object or other explicit methods.
 Use a FOP owned interface like javax.transform.ErrorListener for
 reporting errors and such, or perhaps even reuse ErrorListener
 (somewhat odd, though).
 Use a javax.transform.URIResolver or a similar FOP owned
 interface for resolving URIs (external graphics source, user
 font file...).
2. Intermediate layer with a class combining a transformer and
 a FO processor instance (optional)
3. Class for embedding into the framework. Provides implementations
 for the URIResolver and the ErrorListener, the latter redirecting
 to the logging toolkit. May read external, user writable configuration
 files. Uses framework for passing options and other parametrisations
 from the outside (command line, servlet request, applet parameter...)

It may be an idea to use the factory pattern like javax.transform:

abstract classe FOProcessorFactory {
  // get a new factory. factory may cache default properties for
  // processors, fonts,...
  static FOProcessorFactory newInstance();
  // create a new processor. a FOProcessor instance is only good
  // for one run, like a Transformer
  abstract FOProcessor newFOProcessor();
  abstract FOProcessor newFOProcessor(<Renderer enumeration>);
  // inherited to generated processors
  abstract void setErrorListener(ErrorListener);
  // inherited to generated processors. use also for example for
  // loading default fonts while creating a new processor instance
  abstract void setURIResolver(URIResolver);
  // set attributes, like font file URIs or even compiled font
  // classes
  abstract void setAttribute(String name, Object value) 
  // perhaps a few shortcuts for transformations
  abstract void setTransformation(Source xsl);
  abstract void setTransformation(Templates);
  // various get methods omitted :-)
}

abstract class FOProcessor {
  abstract void setRenderer(<Renderer enumeration>);
  abstract void render(Source,OutputStream);

  abstract void setErrorListener(ErrorListener);
  abstract void setURIResolver(URIResolver);
  abstract void setAttribute(String name, Object value) 
  // shortcuts
  abstract void setTransformation(Source xsl);
  abstract void setTransformation(Templates);
  // extra shortcut (makes no sense for the factory)
  abstract void setTransformation(Transformer);
}

If a transformation is set, the Source in render() is the original
XML piped through the transformation. I'm not sure whether get/set/
clearParameter for the transformation should be added to FOProcessor,
fortunately, no output properties are necessary.
There could be all kind of embeddings or standalone applications
provided based on this interfaces. AWT rendering may need some more
thought, i have no experience how this works. I'm uneasy about
creating renderer objects separately, but it may be necessary.

Regards
J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to