javaxsltibm-content-navigator

Using XSLT from within an IBM Content Navigator plugin


I have a plugin for IBM Content Navigator where a user will send a request to the server, and the server will then apply an XSLT transform on an XML file stored in FileNet.

I also use the same code in a stand alone Java application so that an admin can also apply the XSLT without using the ICN interface.

I am trying to place the XSLT inside my plugin Jar file, and read using:

InputStream xslt = java.lang.ClassLoader.getSystemResourceAsStream("removeStamp.xslt");
Transformer transformer = factory.newTransformer(new StreamSource( xslt));

This works for the Java stand alone application, but not for the ICN Plugin.

How can I use an XSLT from within an IBM Content Navigator plugin jar?


Solution

  • I belive this happens due to that the resource is not found, usually you can find the resource:

    If within the same package

    InputStream is = <your class name>.class.getResourceAsStream("removeStamp.xslt");
    

    How you are searching makes it look for the file in the root of the classpath. to do so you could use

    InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("com/domain/appname/removeStamp.xslt");

    The nuclear option is to add the file in the VM classpath root directory (which is not good, but it would work)