Barcode4j なんで?
http://barcode4j.krysalis.org/fop-ext.html に書いてある通りにやっているつもりなんですが、以下の例外が発生。だめだー。
org.apache.fop.apps.FOPException: java.lang.NoSuchMethodException: For extension function, could not find method org.apache.xml.dtm.ref.DTMNodeIterator.generate([ExpressionContext,] #NODESET). at org.apache.fop.apps.TraxInputHandler.run(TraxInputHandler.java:201) at org.apache.fop.apps.XSLTInputHandler.run(XSLTInputHandler.java:103) at CodeSnippet_2.run(CodeSnippet_2.java:13) at org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain1.eval(ScrapbookMain1.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain.evalLoop(ScrapbookMain.java:54) at org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain.main(ScrapbookMain.java:35)
今度は自分の作ったXSLだとイマイチ怪しいんで、サンプルで試しています。
/barcode4j-1.0rc1/examples/xsl-fo/ の invoice.xml と invoice2xsl-fo.xsl からPDFを作成しようとしています。
まずコマンドラインから。
fop -xml invoice.xml -xsl invoice2xsl-fo.xsl -pdf invoice.pdf
これはちゃんと動いて、PDFが作成できます*1。でもJavaのコードから
XSLTInputHandler input = new XSLTInputHandler( new File("D:/dev/sourceforge.org/barcode4j-1.0rc1/examples/xsl-fo/invoice.xml"), new File("D:/dev/sourceforge.org/barcode4j-1.0rc1/examples/xsl-fo/invoice2xsl-fo.xsl")); OutputStream out = new FileOutputStream("D:/dev/sourceforge.org/barcode4j-1.0rc1/examples/xsl-fo/invoice.pdf"); Driver driver = new Driver(); driver.setRenderer(Driver.RENDER_PDF); driver.setOutputStream(out); input.run(driver);
通りません。前述の例外が発生してしまいます。なんでかわかんないよー。ドキュメントに書いてないんだけどー。なぜー?どうもnamespaceがちゃんと解決されていない感じなんだけど、どこから手を付けたもんだか。
*1:ドキュメントにあるとおりfop.batのクラスパスも変更してあります。