At 02:43 PM 5/19/2005, you wrote:
I've correct the expression to self::db:footnote. For some reason that's
never seemed intuitive to me (obviously).
Yes, it's a little bizarre until you get used to it.
The trick is to remember
(1) that = or equality does *not* test for node type or node identity
(2) node type is easily enough tested with node tests like "*" or "node()"
or "name" as long as you know the axis you want to look at. ("Node test" is
a formal technical term in XPath; learning what a node test is can be very
helpful.) Since XPath will default to the child:: axis if your axis is not
named, that means you have to do the extra work of checking on the self::
axis if you want to traverse to the node itself.
Since a node-set, coerced to a Boolean, is false for an empty set and true
for a set with any nodes in it, test="self::element" will test true if the
context node is an "element" element (since starting from an "element"
element there is indeed an "element" element on the self:: axis).
So, it all hangs together ... but it takes practice, since a number of
non-obvious design features of XPath combine to get the behavior. Note that
while these come to seem normal enough once you're comfortable with the way
XPath location paths are put together, they can also combine to result in
more weirdness. (Languages seem to be like that: no matter what the design
there are always edge cases.)
For example, self::* will return true for elements, but false when the
context node is an attribute, comment, processing instruction, text node or
the root (because of the way "*" is defined).
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================