• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Need Help with Obj-C -> Java bridge method calls with multiple arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need Help with Obj-C -> Java bridge method calls with multiple arguments


  • Subject: Need Help with Obj-C -> Java bridge method calls with multiple arguments
  • From: Marc Liyanage <email@hidden>
  • Date: Tue, 27 May 2003 00:28:27 +0200

Hi list :-)

Maybe someone here has a hint about this:


I read the excellent intro to the ObjC/Java bridge at http://cocoadevcentral.com/articles/000024.php as well as Apple's docs about this.


I am trying to use some Java XML/XSLT classes:

- (IBAction)doSomething:(id)sender
{

NSString *xsltData = @"<?xml version='1.0' encoding='iso-8859-1'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match='/root'>+-<xsl:value-of select='@blah'/>-+</xsl:template>
</xsl:stylesheet>";

NSString *xmlData = @"<?xml version='1.0' encoding='iso-8859-1'?><root blah='hi'/>";

id transformerFactoryClass = NSClassFromString(@"javax.xml.transform.TransformerFactory");
id transformerFactory = [transformerFactoryClass newInstance];

id stringReaderXslt = [NSClassFromString(@"java.io.StringReader") newWithSignature:@"(Ljava/lang/String;)", xsltData];
id streamSourceXslt = [NSClassFromString(@"javax.xml.transform.stream.StreamSource") newWithSignature:@"(Ljava/io/Reader;)", stringReaderXslt];

id stringReaderXml = [NSClassFromString(@"java.io.StringReader") newWithSignature:@"(Ljava/lang/String;)", xmlData];
id streamSourceXml = [NSClassFromString(@"javax.xml.transform.stream.StreamSource") newWithSignature:@"(Ljava/io/Reader;)", stringReaderXml];


// Transformer *transformer = [transformerFactory newTransformer:streamSourceXslt];
id transformer = [transformerFactory newTransformer:streamSourceXslt];

id stringWriter = [[NSClassFromString(@"java.io.StringWriter") alloc] init];
id streamResult = [NSClassFromString(@"javax.xml.transform.stream.StreamResult") newWithSignature:@"(Ljava/io/Writer;)", stringWriter];

////////////// everything works nicely until here. The next statement causes a run-time error //////////////

[transformer transform:streamSourceXml dummy:streamResult];

// NSLog(@"%@", streamSourceXml);

}


My problem is that the transform method takes two arguments. Now, the Apple docs say that

transform:streamSourceXml dummy:streamResult

will be translated to

transform(streamSourceXml, streamResult);


which is what I want. But if I run it, I get this:

2003-05-27 00:22:10.570 javabridgetest[2162] *** -[org/apache/xalan/transformer/TransformerImpl transform:dummy:]: selector not recognized
2003-05-27 00:22:10.581 javabridgetest[2162] *** -[org/apache/xalan/transformer/TransformerImpl transform:dummy:]: selector not recognized

No matter what I try, the selector is not recognized. I'm pretty sure the org/apache/xalan/transformer/TransformerImpl class has this method, I checked the docs as well as the actual binary with "javap".


For fun I tried [transformer transform:streamSourceXml:streamResult];

This was the only thing to produce different output:

2003-05-27 00:05:47.761 javabridgetest[2138] java/lang/NullPointerException
Stack Trace:
java.lang.NullPointerException
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerI mpl.java:1221)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl. java:671)

javabridgetest has exited with status 0.


Is there something I can do about this? How can I call this method? Do I have to write some nice headers to declare the methods? I tried

@interface Transformer : NSObject
{}

- (void)transform:(id)source result:(id)result;

@end

with the invocation [transformer transform:streamSourceXml result:streamResult];




Please CC me on any replies to the list...



Thanks

-Marc






_________________________________________________________________
Marc Liyanage email@hidden
http://www.entropy.ch
ICQ 5077985

Yoda I am. Grammar I can't.
_________________________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Need Help with Obj-C -> Java bridge method calls with multiple arguments
      • From: James Montgomerie <email@hidden>
References: 
 >Re: Future Objective-C changes (From: James Duncan Davidson <email@hidden>)

  • Prev by Date: Re: Blurry NSImages?
  • Next by Date: Customizing appearance of NSTabView
  • Previous by thread: Re: Future Objective-C changes
  • Next by thread: Re: Need Help with Obj-C -> Java bridge method calls with multiple arguments
  • Index(es):
    • Date
    • Thread