| SimonG 2007-07-27, 8:09 am |
| On Jul 27, 5:51 am, "Kuberan Naganathan" <kube...@att.net> wrote:
> Hi.
>
> I recently used the tcl dom module and encountered some problems w/ crashes
> of the interpreter when I tried to
> get child nodes of #text element.
>
> When I switched to dom::tcl, the crashes stopped.
>
> This happens in the latest activestate distribution.
>
> Does anyone know of utilities which can be used to construct an xpath uri in
> tcl? The brackets used in the xpath
> language conflict with tcl's brackets heavily.
>
> Say I have something like this:
>
> set xpathQuery "someTag/someOtherTag\[@attribute\]/attribute::attribute"
>
> I have reason to believe that the backslashes are not removed from the
> string. I find that queries of the above form do not
> work and queries of the form:
>
> set xpathQuery "someTag/someOtherTag"
> append xpathQuery {[@attribute]/attribute::attribute} do work.
>
> Maybe I'm missing something small that's causing a problem. In this case, I
> did find a work around. However, I have
> more experience with tcl than the average programmer I work with. It's
> tough to convince others that tcl is a good choice
> of language for multi-platform programming projects when I spend more time
> than I want to mention trying to figure out
> what went wrong in this query.
>
> I feel that it's issues like this that may turn some programmers away to
> competing technologies. For example, I think that
> the chance of the Java VM becoming corrupt or otherwise crashing due to a
> flaw in a script is much less than the chance of
> this sort of thing in tcl. And the string handling in perl is more
> intuitive. It's also easier to extract individual characters from a
> string in perl.
>
> That's not to say that I don't like tcl. It's just that I find it to have
> some flaws which are more than insignificant.
>
> Can someone give me some insight into how to handle string issues like this
> better? Are there packages that do a better
> job of handling strings than the tcl string command?
>
> Thanks.
>
> P.S.
>
> I've noticed that the volume of postings to this newsgroup seem to have
> declined. Is there a reason for this?
I have a little app I use at work to do xpath queries on large (~60MB)
XML files (commercial offerings don't handle this size well); it uses
the tdom package. I type the XPath into an entry box and use the
following:
if {[catch {$rootNode selectNodes $::xpq} nodes]} {
puts "Malformed XPath $::xpq"
return
}
::xpq is the textvariable for the entry box. Example XPaths are
//Curve[position()>=5 and position()<=20]
and
//Curve[@id="ID_987asd"]
no escaping of brackets or " necessary.
Simon Geard
|