From: Dennis <mai...@ya...> - 2003-06-16 11:51:26
|
Thanks for your reply. Some more help is needed: I wrote a Jython script to which I compile to a java class and call thru a java program. The same thing runs thru command line after removing "self" from the printDocument method ...why to remove self??? If same thing I want to perform using the PythonInterpreter in my java code, How to do it??? Here goes the script import org.w3c.dom as dom import org.apache.xerces as xerces import java.io as io from java import lang class TransformDemo(lang.Object): def __init__(self): "@sig public TransformDemo()" def printDocument(self, domDoc): "@sig public java.lang.String printDocument(org.w3c.dom.Document domDoc)" print "Printing CommonType" rootElement = domDoc.documentElement ntdElement = rootElement.getElementsByTagName("NTD").item(0) loginElement = ntdElement.getElementsByTagName("loginname").item(0) fElement = ntdElement.getElementsByTagName("first").item(0) lElement = ntdElement.getElementsByTagName("last").item(0) domainElement = ntdElement.getElementsByTagName("domain").item(0) result = "<Person><IEmail>" + loginElement.firstChild.nodeValue.strip().lower() + "@" + domainElement.firstChild.nodeValue + "</IEmail><EEmail>" + fElement.firstChild.nodeValue.lower() + "." + lElement.firstChild.nodeValue.lower() + "@yahoo.com" + "</EEmail><FName>" + fElement.firstChild.nodeValue + "</FName><LName>" + lElement.firstChild.nodeValue + "</LName></Person>" print result return result if __name__ == "__main__": print "main method called" parser = xerces.parsers.DOMParser() parser.parse("textron.xml") printDocument(parser.document) Please guide... Thanks Dennis __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com |