Re: Help: I cannot selectNodes with a simple XPath expression



On Apr 29, 5:53 pm, dkf <donal.k.fell...@xxxxxxxxx> wrote:
On 30 Apr, 01:01, "tom.rmadilo" <tom.rmad...@xxxxxxxxx> wrote:

You know, I think the problem is trying to use xsl or xml namespace
semantics in a tcl script.

No. People using other languages have exactly the same problem; I know
for sure that other specifications have to have ugly stuff in them to
work around it. IMO, it's a place where W3C botched the standards qnd,
especially, how the standards work together. (The issue is that
there's no conceptual way to specify a string that knows about the
current namespace context other than a QName, which is rather too
restrictive. Or perhaps the issue is that XML Namespaces are massively
overcomplex for the job. Or perhaps it's that namespace support in
XPath is a failed hack-job. In any case, there's a big impedance
mismatch.) To say that it's Tcl's (or Tcldom's or Tdom's) fault is
wrong; they're just caught in the middle, like everyone else.

About the best thing I can say about XML and all the *** children
of the eXtremely Messed-up Language is that it is better than LDAP.
Actually it is a lot better than LDAP, but that isn't saying much. Any
problems are definitely not due to Tcl, tDom or whatever. It is
possible to use it for very simple things, but if you really want a
simple "data language", check out rmadilo:
http://rmadilo.com/files/rmadilo/latest/doc/whatIsRmadilo.html

If the XPath expression originates from outside the document (i.e.,
your program has it hard-coded) then you need to also code in the
namespace mapping that you're using. If the XPath comes from inside
the document (as an element's or attribute's content) you need
additional places to allow for manual statement of the namespace
mapping to use: you can't just use the normal prevailing ones because
strings can't "know" about those. (Yes, this is stupid.)

Whoever invented XML must have thought that computers could understand
"self-described" data. The only useful part of this entire language is
a subset of XML-Schema, unfortunately nobody seems to write software
to use it. I also think it is somewhat useful to have a generic parser
to pull data into memory, but it is a thousand times more complicated
than a Tcl parser. When I use XML data, I use tDom's toList output to
create a nested Tcl namespace which fully represents the document. Of
course this is only good for pure data applications, if you want to do
a lot of transformations, xslt seems easier.
.