I agree with Dave that this is not a STAF/STAX problem/question. Running a standalone Jython program or Java application that uses the same methods to get the node name of the root element's 2nd element does not work as you expected unless the config.xml file contains line breaks.
Note that you were not doing error checking in your code to get the 'ver'. You should have checked if nodebegin.getLength() > 1 before trying to access the 2nd node within it. For example, the following code would print the error message instead of getting a Python error trying to call getNodeName() on the None object: ver = None begin = document.getDocumentElement() nodebegin = begin.getChildNodes() if nodebegin.getLength() > 1: ver = nodebegin.item(1).getNodeName() else: print "The root element in the xml file only has %s child so cannot access its 2nd child" % (nodebegin.getLength()) print 'ver=%s' % (ver) If you are simply trying to get the name of the 2nd element contained in the xml document's root element, you could do this successfully using the following code instead which assigns ver=unix_r12: ver = None nodeList = document.getElementsByTagName("operating_system") if nodeList.getLength(): node = nodeList.item(0) if node.getNodeType() == Node.ELEMENT_NODE: children = node.getChildNodes() if children.getLength() > 0: thisChild = children.item(0) ver = thisChild.getNodeName() print 'ver=%s' % (ver) -------------------------------------------------------------- Sharon Lucas IBM Austin, luc...@us.ibm.com (512) 286-7313 or Tieline 363-7313 ----- Forwarded by Sharon Lucas/Austin/IBM on 03/15/2010 01:26 PM ----- David Bender/Austin/i...@ibmus 03/15/2010 12:55 PM To Sangram Bakshi <san...@gmail.com> cc staf-users@lists.sourceforge.net Subject Re: [staf-users] Getting attribut error "AttributeError: 'None' object has no attribute 'getNodeName'" on parsign a xml file. It seems to be a Java issue. If I create a standalone Java application (see the attached parse.java file) that does the same parsing as your parsejob.xml file, it gets a NullPointerException (unless I change the formatting of the config.xml file): $ java parse machine_name=etr6506l3-sun66.ca.com prerequisitescript=update.exp acbuildpath=/CR_80SP1/80_builds/Unix/CR16/TestFix testsuitscript=runQuickSanity.sh reportname=BATReport testdir=/testQuickSanity testconfig=BlueExpress.tar java.lang.NullPointerException at parse.main(parse.java:198) Line 198 in the parse.java file is: String ver = nodebegin.item(1).getNodeName(); which is the equivalent line (560) in your parsejob.xml file that gets the error: ver = nodebegin.item(1).getNodeName() AttributeError: 'None' object has no attribute 'getNodeName' So it seems that unless you change the formatting of the config.xml file, nodebegin.item(1) is null. (See attached file: parse.java) Thanks, David David Bender STAF/STAX Development IBM Software Group, WPLC 11501 Burnet Rd. Bldg. 903-5B002 Austin, TX 78758-3400 Phone (T/L): 1-512-286-5315 (363-5315) ITN: 23635315 Email: bda...@us.ibm.com Sangram Bakshi ---03/15/2010 10:48:16 AM---Hi David , I am generating the xml file through dom in javascript. The same xml file i From: Sangram Bakshi <san...@gmail.com> To: David Bender/Austin/i...@ibmus Cc: staf-users@lists.sourceforge.net Date: 03/15/2010 10:48 AM Subject: Re: [staf-users] Getting attribut error "AttributeError: 'None' object has no attribute 'getNodeName'" on parsign a xml file. Hi David , I am generating the xml file through dom in javascript. The same xml file i can read through javascript dom methods , i am able to read the xml even if it is not formatted as you say. I am attaching here the code for that . Try this asp file try to read the xml from "c:/config.xml". But the same xml file i am not able to read from staf job. But surprisingly if i open it in a editor , do nothing and simply save the file , it gets read from staf job. I am not sure if this is some xml encoding problem. I was able to read similar xml file before from staf. Regards Sangram On Mon, Mar 15, 2010 at 7:17 PM, David Bender <bda...@us.ibm.com> wrote: The config.xml file is not formatted correctly. When I open it, the elements are all on a single line: <?xml version="1.0" encoding="utf-8"?> <operating_system><unix_r12><tests type="quickSanityTest"><prerequisitescript>update.exp</prerequisitescript><acbuildpath>/CR_80SP1/80_builds/Unix/CR16/TestFix</acbuildpath><testsuitscript>runQuickSanity.sh</testsuitscript><testdir>/testQuickSanity</testdir><testconfig>BlueExpress.tar</testconfig><reportname>BATReport</reportname></tests><machine_name> etr6506l3-sun66.ca.com</machine_name></unix_r12></operating_system> And when I run your parsejob.xml job with the config.xml file, I get the same error. If I format the config.xml file as: <?xml version="1.0" encoding="utf-8"?> <operating_system> <unix_r12> <tests type="quickSanityTest"> <prerequisitescript>update.exp</prerequisitescript> <acbuildpath>/CR_80SP1/80_builds/Unix/CR16/TestFix</acbuildpath> <testsuitscript>runQuickSanity.sh</testsuitscript> <testdir>/testQuickSanity</testdir> <testconfig>BlueExpress.tar</testconfig> <reportname>BATReport</reportname> </tests> <machine_name>etr6506l3-sun66.ca.com</machine_name> </unix_r12> </operating_system> Then the error no longer occurs when running parsejob.xml. Thanks, David David Bender STAF/STAX Development IBM Software Group, WPLC 11501 Burnet Rd. Bldg. 903-5B002 Austin, TX 78758-3400 Phone (T/L): 1-512-286-5315 (363-5315) ITN: 23635315 Email: bda...@us.ibm.com Sangram Bakshi ---03/15/2010 04:59:01 AM---Hi , I am encountering the following error : From: Sangram Bakshi <san...@gmail.com> To: staf-users@lists.sourceforge.net Date: 03/15/2010 04:59 AM Subject: [staf-users] Getting attribut error "AttributeError: 'None' object has no attribute 'getNodeName'" on parsign a xml file. Hi , I am encountering the following error : "AttributeError: 'None' object has no attribute 'getNodeName'" on parsing a xml file." This a new problem i am getting , never earlier got this problem . The xml file to be parsed is : ===================== <?xml version="1.0" encoding="utf-8"?> <operating_system> <unix_r12> <tests type="quickSanityTest"> <prerequisitescript>update.exp</prerequisitescript> <acbuildpath>/CR_80SP1/80_builds/Unix/CR16/TestFix</acbuildpath> <testsuitscript>runQuickSanity.sh</testsuitscript> <testdir>/testQuickSanity</testdir> <testconfig>BlueExpress.tar</testconfig> <reportname>BATReport</reportname> </tests> <machine_name>etr6506l3-sun66.ca.com</machine_name> </unix_r12> </operating_system> Attached is the exact file that i am using to parse: The staf job file "parsejob.xml is also attached here: I get the error : 20100315-15:09:48 STAXPythonEvaluationError signal raised. Terminating job. ===== XML Information ===== File: C:\STAF\stax_jobs\parsejob.xml, Machine: baksa03-xp.ca.com Line 403: Error in element type "script". ===== Python Error Information ===== com.ibm.staf.service.stax.STAXPythonEvaluationException: Traceback (innermost last): File "<pyExec string>", line 157, in ? AttributeError: 'None' object has no attribute 'getNodeName' ===== Call Stack for STAX Thread 1 ===== [ function: Main (Line: 8, File: C:\STAF\stax_jobs\parsejob.xml, Machine: baksa03-xp.ca.com) sequence: 1/31 (Line: 10, File: C:\STAF\stax_jobs\parsejob.xml, Machine: baksa03-xp.ca.com) function: parseXML (Line: 383, File: C:\STAF\stax_jobs\parsejob.xml, Machine: baksa03-xp.ca.com) sequence: 2/4 (Line: 391, File: C:\STAF\stax_jobs\parsejob.xml, Machine: baksa03-xp.ca.com) ] I have validated the xml file to be valid by MSXML valid . It is valid . Now the same xml file gets read if i Ctrl-x the following in the xml file : <tests type="quickSanityTest"> <prerequisitescript>update.exp</prerequisitescript> <acbuildpath>/CR_80SP1/80_builds/Unix/CR16/TestFix</acbuildpath> <testsuitscript>runQuickSanity.sh</testsuitscript> <testdir>/testQuickSanity</testdir> <testconfig>BlueExpress.tar</testconfig> <reportname>BATReport</reportname> and paste it again at the same location in the xml file. The xml file then gets parsed through the staf job as i have attched. Please suggest , i am not understanding this problem . Regards Sangram [attachment "config.xml" deleted by David Bender/Austin/IBM] [attachment "parsejob.xml" deleted by David Bender/Austin/IBM] ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users [attachment "try22.asp" deleted by David Bender/Austin/IBM] ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users[attachment "parse.java" deleted by Sharon Lucas/Austin/IBM] ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
<<image/gif>>
------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users