more release 2.8 checkins
Marc Liyanage [Wed, 20 Aug 2003 09:59:32 +0000 (09:59 +0000)]
git-svn-id: svn+ssh://www.entropy.ch/Users/liyanage/Documents/svnroot/trunk/TestXSLT@52 153f8dbc-cef0-0310-8e0e-ba1d6c9f8c6b

13 files changed:
FOP/avalon-framework-cvs-20020806.jar [new file with mode: 0644]
FOP/batik.jar [new file with mode: 0644]
FOP/fop.jar [new file with mode: 0644]
FOPWrapper.java [new file with mode: 0644]
XSLTProcessorJAXPBase.h [new file with mode: 0644]
XSLTProcessorJAXPBase.m [new file with mode: 0644]
XSLTProcessorXalan_J.h [new file with mode: 0644]
XSLTProcessorXalan_J.m [new file with mode: 0644]
XSL_FO_Renderer.h [new file with mode: 0644]
XSL_FO_Renderer.m [new file with mode: 0644]
Xalan-J/xalan-2.4.1.jar [new file with mode: 0644]
Xalan-J/xercesImpl-2.2.1.jar [new file with mode: 0644]
Xalan-J/xml-apis.jar [new file with mode: 0644]

diff --git a/FOP/avalon-framework-cvs-20020806.jar b/FOP/avalon-framework-cvs-20020806.jar
new file mode 100644 (file)
index 0000000..7db7299
Binary files /dev/null and b/FOP/avalon-framework-cvs-20020806.jar differ
diff --git a/FOP/batik.jar b/FOP/batik.jar
new file mode 100644 (file)
index 0000000..28c8bac
Binary files /dev/null and b/FOP/batik.jar differ
diff --git a/FOP/fop.jar b/FOP/fop.jar
new file mode 100644 (file)
index 0000000..f7a3a2c
Binary files /dev/null and b/FOP/fop.jar differ
diff --git a/FOPWrapper.java b/FOPWrapper.java
new file mode 100644 (file)
index 0000000..9a97769
--- /dev/null
@@ -0,0 +1,107 @@
+
+import java.io.*;
+
+import org.xml.sax.*;
+import com.apple.cocoa.foundation.NSData;
+
+//Avalon
+import org.apache.avalon.framework.ExceptionUtil;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.logger.ConsoleLogger;
+
+//FOP
+import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.messaging.MessageHandler;
+
+/**
+ * This class helps calling FOP from the Obj-C side.
+ * Based on "ExampleFO2PDF.java" from the FOP project.
+ */
+public class FOPWrapper {
+
+    String error;
+    boolean errorOccurred = false;
+       
+       public NSData convert(String foString) throws IOException, FOPException {
+        
+               //Construct driver
+               Driver driver = new Driver();
+        
+               //Setup logger
+               Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
+               driver.setLogger(logger);
+               MessageHandler.setScreenLogger(logger);
+               
+               //Setup Renderer (output format)        
+               driver.setRenderer(Driver.RENDER_PDF);
+        
+               //Setup output
+               ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
+               try {
+                       driver.setOutputStream(out);
+                       
+                       //Setup input
+                       InputStream in = new java.io.ByteArrayInputStream(foString.getBytes("UTF-8"));
+                       try {
+                               driver.setInputSource(new InputSource(in));
+                               
+                               //Process FO
+                               driver.run();
+                       } catch (Exception e) {
+                               error = e.toString();
+                               errorOccurred = true;
+                       } finally {
+                               in.close();
+                       }
+                       
+               } finally {
+                       out.close();
+               }
+               
+               return new NSData(out.toByteArray());
+               
+       }
+       
+       public String getErrorMessage() {
+               return error;
+       }
+       
+       public boolean errorOccurred() {
+               return errorOccurred;
+       }
+       
+       
+       /*
+    public static void main(String[] args) {
+        try {
+            System.out.println("FOP ExampleFO2PDF\n");
+            System.out.println("Preparing...");
+            
+            //Setup directories
+            File baseDir = new File(".");
+            File outDir = new File(baseDir, "out");
+            outDir.mkdirs();
+                       
+            //Setup input and output files            
+            File fofile = new File(baseDir, "xml/fo/helloworld.fo");
+            File pdffile = new File(outDir, "ResultFO2PDF.pdf");
+                       
+            System.out.println("Input: XSL-FO (" + fofile + ")");
+            System.out.println("Output: PDF (" + pdffile + ")");
+            System.out.println();
+            System.out.println("Transforming...");
+            
+            FOPWrapper app = new FOPWrapper();
+            app.convertFO2PDF(fofile, pdffile);
+            
+            System.out.println("Success!");
+        } catch (Exception e) {
+            System.err.println(ExceptionUtil.printStackTrace(e));
+            System.exit(-1);
+        }
+    }
+        
+        */
+       
+}
diff --git a/XSLTProcessorJAXPBase.h b/XSLTProcessorJAXPBase.h
new file mode 100644 (file)
index 0000000..eba6a2c
--- /dev/null
@@ -0,0 +1,34 @@
+//
+//  XSLTProcessorJAXPBase.h
+//  TestXSLT
+//
+//  Created by Marc Liyanage on Mon Aug 18 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "XSLTProcessor.h"
+
+
+
+@interface XSLTProcessorJAXPBase : XSLTProcessor {
+
+}
+
+- (NSString *) getJAXPProcessorName;
+
+
+@end
+
+
+// Java class declarations to keep the compiler happy
+
+@interface JAXPWrapper : NSObject
+{}
+- (int)getErrorSource;
+- (int)getErrorLine;
+- (NSString *)getErrorMessage;
+- (NSString *)getResult;
+- (BOOL)transform:(NSString *)processorClassName :(NSString *)xml :(NSString *)xslt :(NSString *)parameters :(NSString *)baseUri;
+@end
+
diff --git a/XSLTProcessorJAXPBase.m b/XSLTProcessorJAXPBase.m
new file mode 100644 (file)
index 0000000..66f5529
--- /dev/null
@@ -0,0 +1,71 @@
+//
+//  XSLTProcessorJAXPBase.m
+//  TestXSLT
+//
+//  Created by Marc Liyanage on Mon Aug 18 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import "XSLTProcessorJAXPBase.h"
+
+
+@implementation XSLTProcessorJAXPBase
+
+
+
+
+
+
+- (BOOL)processStrings:(NSString *)xmlCode withXslt:(NSString *)xsltCode andParameters:(const char **)params {
+       
+       [self clearError];
+       
+       NSString *jaxpBaseUri = @"";
+       if ([self baseUri] != nil) {
+               jaxpBaseUri = [self baseUri];
+       }
+       
+       
+       NSMutableString *paramBuffer = [[NSMutableString alloc] init];
+       int i = 0;
+       while (params && params[i]) {
+               
+               [paramBuffer appendString:[NSString stringWithFormat:@"%s==_=!=_==%s", params[i], params[i+1]]];
+               
+               if (params[i+2]) {
+                       // more parameters to follow
+                       [paramBuffer appendString:@"--_-!-_--"];
+               }
+               
+               i += 2;
+       }
+       
+       JAXPWrapper *jw = (JAXPWrapper *)[[NSClassFromString(@"JAXPWrapper") alloc] init];
+       BOOL swresult = [jw transform:[self getJAXPProcessorName] :xmlCode :xsltCode :paramBuffer :jaxpBaseUri];
+       
+       
+       
+       if (swresult) {
+               [self setResult:[jw getResult]];
+       } else {
+               [self setError:[jw getErrorMessage] atLine:[jw getErrorLine] inSource:[jw getErrorSource]];     
+       }
+       
+       
+       [jw release];
+       
+       return ![self errorOccurred];
+       
+}
+
+
+- (NSString *) getJAXPProcessorName {
+       
+       NSLog(@"subclass must override getJAXPProcessorName in XSLTProcessorJAXPBase!");
+       return nil;
+       
+}
+
+
+
+@end
diff --git a/XSLTProcessorXalan_J.h b/XSLTProcessorXalan_J.h
new file mode 100644 (file)
index 0000000..cc58a04
--- /dev/null
@@ -0,0 +1,17 @@
+//
+//  XSLTProcessorXalan_J.h
+//  TestXSLT
+//
+//  Created by Marc Liyanage on Mon Aug 18 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import "XSLTProcessorJAXPBase.h"
+
+
+@interface XSLTProcessorXalan_J : XSLTProcessorJAXPBase {
+       
+}
+
+@end
+
diff --git a/XSLTProcessorXalan_J.m b/XSLTProcessorXalan_J.m
new file mode 100644 (file)
index 0000000..e4961b4
--- /dev/null
@@ -0,0 +1,29 @@
+//
+//  XSLTProcessorXalan_J.m
+//  TestXSLT
+//
+//  Created by Marc Liyanage on Mon Aug 18 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import "XSLTProcessorXalan_J.h"
+
+
+@implementation XSLTProcessorXalan_J
+
+
+- (int)processorType {
+       
+       return PROCESSORTYPE_XALAN_J;
+       
+}
+
+
+- (NSString *) getJAXPProcessorName {
+       
+       return @"org.apache.xalan.processor.TransformerFactoryImpl";
+       
+}
+
+
+@end
diff --git a/XSL_FO_Renderer.h b/XSL_FO_Renderer.h
new file mode 100644 (file)
index 0000000..802db8d
--- /dev/null
@@ -0,0 +1,34 @@
+//
+//  XSL_FO_Renderer.h
+//  TestXSLT
+//
+//  Created by Marc Liyanage on Tue Aug 19 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface XSL_FO_Renderer : NSObject {
+
+}
+
+- (NSData *)render:(NSString *)foString;
+
+@end
+
+// Java class declarations to keep the compiler happy
+
+@interface FOPWrapper : NSObject
+{}
+/*
+- (int)getErrorSource;
+- (int)getErrorLine;
+- (NSString *)getResult;
+*/
+
+- (NSString *)getErrorMessage;
+- (BOOL)errorOccurred;
+- (NSData *)convert:(NSString *)foString;
+
+@end
diff --git a/XSL_FO_Renderer.m b/XSL_FO_Renderer.m
new file mode 100644 (file)
index 0000000..5db7e68
--- /dev/null
@@ -0,0 +1,32 @@
+//
+//  XSL_FO_Renderer.m
+//  TestXSLT
+//
+//  Created by Marc Liyanage on Tue Aug 19 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import "XSL_FO_Renderer.h"
+
+
+@implementation XSL_FO_Renderer
+
+
+- (NSData *)render:(NSString *)foString {
+
+       FOPWrapper *fw = (FOPWrapper *)[[NSClassFromString(@"FOPWrapper") alloc] init];
+
+       NSData *resultData = [fw convert:foString];
+       
+       // fixme: autorelease on resultData? creation on Java side?
+       
+       [fw release];
+       
+       //NSLog(@"data: %@", resultData);
+       
+       return resultData;
+}
+
+
+
+@end
diff --git a/Xalan-J/xalan-2.4.1.jar b/Xalan-J/xalan-2.4.1.jar
new file mode 100644 (file)
index 0000000..3e50f5f
Binary files /dev/null and b/Xalan-J/xalan-2.4.1.jar differ
diff --git a/Xalan-J/xercesImpl-2.2.1.jar b/Xalan-J/xercesImpl-2.2.1.jar
new file mode 100644 (file)
index 0000000..bdb2de6
Binary files /dev/null and b/Xalan-J/xercesImpl-2.2.1.jar differ
diff --git a/Xalan-J/xml-apis.jar b/Xalan-J/xml-apis.jar
new file mode 100644 (file)
index 0000000..f380b9d
Binary files /dev/null and b/Xalan-J/xml-apis.jar differ