--- Finn Bock <[EMAIL PROTECTED]> wrote: > > I don't want to change any FOP code! And if I have > to change any FOP > sources to add an extension, then FOP doesn't > support extension with the > meaning of extension as I understand it. >
>From what I understand a program may not change its own source code while it is running so we may not have complete freedom for everything. > An extension mechanism where I can put an unmodified > fop.jar and > myextension.jar on the CLASSPATH and have it work is > a defining issue to > me. OK, this looks like a nice feature to have, and the modifications made to FOP in this regard can be helpful to others who have similar work to do. Here's what I see: Option #1: 1.) myextension.jar will need a FOElementMapping [1] subclass that will reroute fo:Block from Block.java to FinnBlock.java. Have FinnBlock.java override the vCN() for the new validation rules. (FinnBlock.java can also override addLayoutManager() if it uses a different one--let's discuss this one if it is an adequate substitute for your need for the LM makers we were discussing earlier.) Ideally, myextension.FinnFOElementMapping can subclass FOElementMapping so you will only need to define makers for the elements you are changing. 2.) FOUserAgent.addElementMapping() [2] is the interface to add an element mapping to runtime FOP. Embedded users wanting to link in your library in their code will need to call foUserAgent.addElementMapping("myextension.fo.FinnFOElementMapping"); 3.) FOTreeBuilder currently loads the "default" mappers first, then checks for any user-added ones [3]. We will need to change this logic to have FOP first load any user-defined (or run-time discovered) element mappings first, then load each of the default ones *if* its namespace hasn't already been loaded. So for the user adding FinnFOElementMapping with the XSL namespace URI, this will result in FOElementMapping *not* being loaded, because it has the same namespace URI. 4.) (If applicable) Finally, for command-line users, subclass apps.Fop java, changing both constructors to load your element mapping: foUserAgent.addElementMapping("FinnFOElementMapping"), and provide a finnfop.bat/.sh that will call this. Option #2: 1.) Same as #1 above. 2.) Provide a subclass of FOTreeBuilder in my extension.java that overrides the method setupDefaultMapping() to load FinnFOElementMapping instead of FOElementMapping. 3.) Same as #4 above. Thoughts? Glen [1] http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/fo/FOElementMapping.java?rev=1.8&view=auto [2] http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/apps/FOUserAgent.java?annotate=1.15#112 [3] http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java?annotate=1.45#124