We have a document schema whose instances will refer to three namespaces.
I need to be able to do xpath queries on instances of this document,
knowing only that it matches the schema, but not, for example, what the
namespace prefixes of the elements are.
Consider:
xmlns:a="http://ns1"
xmlns:b="http://ns2"
xmlns:c="http://ns3"
<a:top>
<b:something>
<c:foo bar="baz" />
</b:something>
<a:top>
Suppose I get an instance of this document, but I have no idea what
prefixes map to which namespaces. I can use TclXML/TclDOM to parse it,
but I have no idea whatsoever about how I associate, say, "ns1" with
the namespace "http://ns1" for xpath queries.
Can someone tell me how to do this?
mail address above is accurate, barring the interleaved spam.
set ns { svg http://www.w3.org/2000/svg }
set svgNode [$root selectNodes -namespaces $ns /*/svg:svg|/svg:svg]
Ramon Ribó
En Sat, 27 May 2006 04:12:33 +0200, Chris R <osfpf...@offlineblog.com>
escribió:
--
Compass Ing. y Sistemas Dr. Ramon Ribo
http://www.compassis.com ram...@compassis.com
c/ Tuset, 8 7-2 tel. +34 93 218 19 89
08006 Barcelona, Spain fax. +34 93 396 97 46
That sounds promising. I'll check that one out, too.
I am somewhat constrained by our existing support for TclXML, though;
I'd be pleased if there were a similar mechanism in place for that
module.
Anyone?
--
Chris R
=======
Not to be taken literally, internally, or seriously
e-mail is accurate, barring the interleaved spam.
Your later post has shown that you have discovered that TclDOM does
indeed have this facility.
Basically, you must declare the equivalent of the XML Namespace
declarations in the XPath call. The TclDOM selectNodes command accepts
the "-namespaces" option for this purpose (bugs notwithstanding ;-)
Cheers,
Steve Ball