You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Michael Mutschler <mi...@mutschler.de> on 2003/08/18 16:18:47 UTC

getting FOP-Version

Hi,

I just tried to figure out, how to obtain the current version of fop.

There is a nice method called
org.apache.fop.apps.Version.getVersion(), which returns null, when you
call it. Not very nice. So I looked a bit more into the source, and I
found the following method to read the configuration:

Class.forName("org.apache.fop.apps.Options").newInstance();

using this before calling the getVersion() above solved the problem,
and I get the String "FOP 0.20.5". But in addition the following lines
are dumped to the console:

[WARNING] Screen logger not set - Using ConsoleLogger.
[INFO] Using org.apache.crimson.parser.XMLReaderImpl as SAX2 Parser

Is this the right method for doing this? Or does it perhaps override a
previously loaded configuration? Right now I am checking for a null of
the getVersion()-call, and make the newInstance() of the Options only
in this case.

The additional lines do not matter that much, because the actual
program is a GUI-Application, and the console is not available, when
running with "javaw".

I am writing a System-dumpinfo-class in case of bugreports, and the
FOP-Version could be quite useful. The code now looks like this
(reflection rules, since it should work when fop is not available too):

try {
    Class c = Class.forName("org.apache.fop.apps.Version");
    String version = (String)c.getMethod("getVersion", NOCLASSES).invoke(null, NOOBJECTS);
    if (version == null) {
        Class.forName("org.apache.fop.apps.Options").newInstance();
        version = (String)c.getMethod("getVersion", NOCLASSES).invoke(null, NOOBJECTS);
    }
    logger.log("FOP-Version: " + version);
} catch (Exception e) {}


-- 
Best regards,
 Michael                          mailto:michael@mutschler.de



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: getting FOP-Version

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Michael Mutschler wrote:
> There is a nice method called
> org.apache.fop.apps.Version.getVersion(), which returns null, when you
> call it.

The version is initialized from the system configuration file, which
is not loaded until an Options object is created. See
  http://xml.apache.org/fop/embedding.html#config-external

> But in addition the following lines
> are dumped to the console:
> 
> [WARNING] Screen logger not set - Using ConsoleLogger.
> [INFO] Using org.apache.crimson.parser.XMLReaderImpl as SAX2 Parser
> 
This is writen by the configuration loader.

J.Pietschmann



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re[2]: getting FOP-Version

Posted by Michael Mutschler <mi...@mutschler.de>.
Hallo Bernd,

Monday, August 18, 2003, 7:10:20 PM, you wrote:

>> I just tried to figure out, how to obtain the current version of fop.
>>
>> There is a nice method called
>> org.apache.fop.apps.Version.getVersion(), which returns null, when you
>> call it. Not very nice.

BB> There must be something wrong with your code. I'm calling the above method
BB> from the XSLT which transforms my input XML file to XSL-FO and get the
BB> version string without problems. (fop-0.20.5)

Then you probably called it after your transformation. Try calling it
before, when FOP ist not yet used for anything else.

-- 
Best regards,
 Michael                            mailto:michael@mutschler.de


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: getting FOP-Version

Posted by Bernd Brandstetter <bb...@freenet.de>.
On Monday 18 August 2003 16:18, Michael Mutschler wrote:
> Hi,
>
> I just tried to figure out, how to obtain the current version of fop.
>
> There is a nice method called
> org.apache.fop.apps.Version.getVersion(), which returns null, when you
> call it. Not very nice.

There must be something wrong with your code. I'm calling the above method 
from the XSLT which transforms my input XML file to XSL-FO and get the 
version string without problems. (fop-0.20.5)

Bye,
Bernd


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org