Re: [tcljava-user] jacl 1.3.1 regexp
Brought to you by:
mdejong
From: Patrick F. <pfi...@oz...> - 2007-04-09 13:16:50
|
On Monday 09 April 2007 13:32, Johannes Kleinlercher wrote: > Hi all, > > I look for a way to parse an XML-File in IBMs wsadmin, which uses jacl > 1.3.1 as a scripting language. > > I found a project called sa4was [1] on IBMs developerworks which does > parsing XML with regexp. sa4was works with WebSpher 5.x (which used jacl > 1.2.x) however in WebSphere 6.0 (which uses jacl 1.3.1) it doesn't work > anymore. > > Some code in sa4was does the following: > > ============================================ > while {[regexp {([^=]+)="([^"]*?)"(.*)} $restOfTag dontCare > attributeName attributeValue restOfTag]} { > if {$attributeName == "id"} { > set idValue $attributeValue > break > } > } > ============================================ > > and there I get the error > "couldn't compile regular expression pattern: nested *?+" > > > I found out that regexp changed in jacl 1.3.1 and non-greedy regexp > (with this "*?" expression) doesn't work anymore. Is that right? > > Questions: > a) So are there workarounds for something like that? > b) Or are there some better ways to parse XML in jacl? > The quick work around for existing sa4was scripts in a WAS 6 environment is to downgrade JACL from 1.3.1 to 1.2.X by replacing the 1.3.1 jacl.jar and tcljava.jar jar files in the was/installdirectory/lib directory. However I would not recommend using sa4was with 6.0 because it's is not supported by IBM in 6.x. I have a JACL script library for WAS which I am posting on the internet this week that covers most of the WAS admin functions. You should have a look at that. The Tcl xml parser TclXml has not been ported to JACL so you need to use 'regexp' or 'string match' to parse XML. If you want to use Tcl packages that have not been ported to JACL in a scripted WebSphere admin environment then you will need to use TclBlend as a java client with the WebSphere JMX java library. There are plenty of articles on Developerworks that describe WAS admin using java clients rather than Wasadmin clients written in Jython or Jacl. I am re-writing most of my stuff to use TclBlend because while IBM might drop support for Jacl and Jython in future releases the JVM layer will always be there. |