On Jan 30, 2008, at 13:01, Jeremias Maerki wrote:

Hi Jeremias, Vincent,

<snip />
However, there's one thing in this context that is still on my list and
that I want to change eventually: We have multiple places where we
create a new TransformerFactory. It's always the platform default that
is used. Some FOP users have asked before that there be a default that
is set to and applies to FOP only, i.e. we need a central
SAXTransformerFactory for FOP.

I agree with the intention, but not with duplicating the endorsed standards mechanism, as noted in the other thread. The context where this is applicable, is not really simple CLI-usage, so my reasoning would be: If an embedding user needs to instantiate the basic TransformerFactory himself, FOP should probably simply keep a reference to that, and use that single factory internally.

For example, a user could decide to force a hard dependency on Saxon:

SAXTransformerFactory tFactory = (SAXTransformerFactory) net.sf.saxon.TransformerFactoryImpl.newInstance()

If we make it possible for him to pass this factory into the FopFactory or FOUserAgent, and we replace all internal references to TransformerFactory to use this instance, that should provide him with more than enough flexibility.

[Vincent:]
Using a TransformerFactory just to serialize data into an XML file may
sound a bit weird (this has nothing to do with XSLT). It appears that
Xerces defines an XMLSerializer class dedicated to that.
<snip />

It's not weird at all, if you look at what is needed to serialize your data into a different format --possibly non-XML.
Using the XMLSerializer, you would either:
a) need a different sort of Serializer (properietary?)
b) if the target is still XML, you /could/ add an XSLT step before the serialization

Now, looking at it this way, why not simply use an identity Transformer to begin with. If your output target changes, all you need to do is write a stylesheet (which is much simpler than implementing your own Serializer), and alter one or two lines of Java code (some more if you also want the stylesheet to be pluggable).


Cheers

Andreas

Reply via email to