There is a problem with the minidom package provided with Jython 2.1 (which is what STAX currently uses). Instead, you may want use a Java DOM Parser to parse an XML file via Jython code within a <script> element in a STAX job. Note that Jython allows you to import and use Java classes (as Jython is the Java implementation of Python) in addition to using Python modules. See section "2.6.7 How can I parse an XML file from a STAX job?" in the STAF/STAX FAQ at http://staf.sourceforge.net/current/STAFFAQ.htm#d0e736 for an example of how to parse an XML file using a Java DOM parser within a <script> element in a STAX job.
Note that if you google for the minidom "AttributeError: feed" error message and Jython 2.1, you'll see that many hits about a problem with the minidom package provided with Jython 2.1. Or, you can search the STAF forums / mailing lists on SourceForge (there's a link to search in the navigation column on the left on the STAF SourceForge home page at http://staf.sourceforge.net) and you'll see that this question has already been asked and answered via: http://sourceforge.net/projects/staf/forums/forum/104046/topic/1727421?message=4292971 -------------------------------------------------------------- Sharon Lucas IBM Austin, luc...@us.ibm.com (512) 286-7313 or Tieline 363-7313 staf-stax user <stafstaxu...@gmail.com> 01/05/2010 11:34 AM To David Bender/Austin/i...@ibmus cc staf-users@lists.sourceforge.net Subject Re: [staf-users] Issues while importing external python modules. Thanks David for information. I tried using minidom xml parser as replacement to lxml. Here is my modified code: ****************************** from xml.dom import minidom ConfileFile1 = 'C:\\test.xml' ConfigFile2 = 'C:\\test1.xml' ATree = minidom.parse(ConfileFile1) CTree = minidom.parse(ConfigFile2) for Element in ATree.getElementsByTagName('Test1'): for Ele in CTree.getElementsByTagName ('Test2'): Element.appendChild(Ele) NewATreeString = ATree.toxml() ****************************** But I am getting below mentioned error Line 11: Error in element type "script". ===== Python Error Information ===== com.ibm.staf.service.stax.STAXPythonEvaluationException: Traceback (innermost last): File "<pyExec string>", line 6, in ? File "C:\STAF\data\STAF\lang\java\shared_jython\2.1-staf-v3.3\Lib\xml\dom\minidom.py", line 908, in parse File "C:\STAF\data\STAF\lang\java\shared_jython\2.1-staf-v3.3\Lib\xml\dom\minidom.py", line 900, in _doparse File "C:\STAF\data\STAF\lang\java\shared_jython\2.1-staf-v3.3\Lib\xml\dom\pulldom.py", line 251, in getEvent AttributeError: feed Regard's On Tue, Jan 5, 2010 at 7:47 PM, David Bender <bda...@us.ibm.com> wrote: Hi, Do the 3 lines in your <script> work for you when running them outside of STAF/STAX? I tried installing lxml-2.2.4.win32-py2.5.exe, and when running from Python 2.5, I got the same error: $ python Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path.append("C:\\Python25\\Lib\\site-packages\\lxml") >>> from lxml import etree Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name etree >>> Looking at the documentation at: http://codespeak.net/lxml/tutorial.html I tried the following and it worked: >>> import xml.etree.cElementTree as etree >>> Having said all that, note that STAX uses Jython V2.1, which is a Java implementation of Python V2.1. It seems that lxml is built for specific versions of Python (and does not appear to support Python 2.1), so I don't think you will be able to use lxml within your STAX job. Using "import xml.etree.cElementTree as etree" within the <script> results in "ImportError: No module named etree". 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 From: staf-stax user <stafstaxu...@gmail.com> To: staf-users@lists.sourceforge.net Cc: staf-stax user <stafstaxu...@gmail.com> Date: 01/05/2010 07:17 AM Subject: [staf-users] Issues while importing external python modules. Hi I am facing issues while importing "lxml" module through STAX. lxml package is installed at location "C:\Python26\Lib\site-packages\lxml". In my stax.xml I am importing this module by appending syspath. Here is how I am trying to import etree under lxml. "etree.pyd" file is present under lxml folder. ************** <script> import sys sys.path.append ("C:\\Python26\\Lib\\site-packages\\lxml") from lxml import etree </script> *************** At this point it is throwing me an error "ImportError: cannot import name etree" Regard's ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users