Initial revision
[TestXSLT.git] / XSLTProcessorSaxon.m
1 //
2 //  XSLTProcessorSaxon.m
3 //  TestXSLT
4 //
5 //  Created by Marc Liyanage on Sun Jun 08 2003.
6 //  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "XSLTProcessorSaxon.h"
10
11
12 @implementation XSLTProcessorSaxon
13
14
15 - (int)processorType {
16
17         return PROCESSORTYPE_SAXON;
18
19 }
20
21
22
23 - (BOOL)processStrings:(NSString *)xmlCode withXslt:(NSString *)xsltCode andParameters:(const char **)params {
24
25         [self clearError];
26
27         NSString *jaxpBaseUri = @"";
28         if ([self baseUri] != nil) {
29                 jaxpBaseUri = [self baseUri];
30         }
31         
32         
33         NSMutableString *paramBuffer = [[NSMutableString alloc] init];
34         int i = 0;
35         while (params && params[i]) {
36
37                 [paramBuffer appendString:[NSString stringWithFormat:@"%s==_=!=_==%s", params[i], params[i+1]]];
38
39                 if (params[i+2]) {
40                         // more parameters to follow
41                         [paramBuffer appendString:@"--_-!-_--"];
42                 }
43                 
44                 i += 2;
45         }
46         
47         JAXPWrapper *jw = (JAXPWrapper *)[[NSClassFromString(@"JAXPWrapper") alloc] init];
48         BOOL swresult = [jw transform:@"com.icl.saxon.TransformerFactoryImpl" :xmlCode :xsltCode :paramBuffer :jaxpBaseUri];
49         
50         
51         
52         if (swresult) {
53                 [self setResult:[jw getResult]];
54         } else {
55                 [self setError:[jw getErrorMessage] atLine:[jw getErrorLine] inSource:[jw getErrorSource]];     
56         }
57         
58                 
59         [jw release];
60         
61         return ![self errorOccurred];
62
63 }
64
65
66
67
68
69 @end