One other XPath enhancement that you can expect sometime soon has to do with proper
namespace support. According to the XPath specification, when expressions contain unqualified element names (no
namespace prefix), the elements are considered part of no
namespace (even if a default
namespace declaration is present in the source document). When XPath expressions contain qualified names (through a
namespace prefix) they are evaluated according to the
namespace bindings that make up the current XPath context. However, there is currently no mechanism in place for establishing
namespace bindings prior to evaluating an XPath expression in
MSXML 3.0. This makes it impossible to properly
query namespace-aware
XML documents.
For example, assuming the following
XML document:
<foo xmlns='urn:foo-bar:baz'>
<bar><baz/></bar>
</foo>
what should be returned by the /foo/bar/baz expression? According to the XPath specification, it should return nothing because it's looking for foo, bar, and baz elements that belong to no
namespace. But in the source document the foo, bar, and baz elements all belong to the urn:foo-bar:baz
namespace.
To solve this problem, in a future release of
MSXML 3.0 it will be possible to specify
namespace bindings through the SelectionNamespaces property before calling selectNodes, as shown here:
doc.setProperty "SelectionNamespaces", _
"xmlns:f='urn:foo-bar:baz'"
set sel = doc.selectNodes("/f:foo/f:bar/f:baz")
With the
namespace bindings in place, this expression should now behave properly because it identifies foo, bar, and baz elements that belong to the 'urn:foo-bar:baz', which matches the default
namespace declaration in the source document. (Note that syntax may change by release time.)