Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Namespaces and XPATH in MSXML 4.0 - Parsing WSDL

0 views
Skip to first unread message

Doug

unread,
Feb 28, 2002, 8:50:23 AM2/28/02
to
Kinda long, but this is driving me nuts! Any insight is
greatly appreciated...

Consider the following wsdl snippet:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Generated 02/27/02 by Microsoft SOAP Toolkit WSDL
File Generator, Version 1.02.813.0-->
<definitions name="encodetest"
targetNamespace="http://tempuri.org/wsdl/"
xmlns:wsdlns="http://tempuri.org/wsdl/"
xmlns:typens="http://tempuri.org/type"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-
extension" xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>
<schema targetNamespace="http://tempuri.org/type"
xmlns="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-
ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
elementFormDefault="qualified" />

</types>
- <message name="EndPoint.PassAString">
<part name="SomeString" type="xsd:string" />
</message>
- <message name="EndPoint.PassAStringResponse">
<part name="Result" type="xsd:string" />
</message>

If I want to find all of the messages with selectNodes, I
need to use the following syntax:

m_dom.setProperty "SelectionNamespaces", "xmlns:wsdl='http:
//schemas.xmlsoap.org/wsdl/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'"

Set MessageList = m_dom.selectNodes("//wsdl:message")

Why must I specify 'wsdl:' to find the messages given the
namespace declarations at the top of the wsdl file?

At first I thought
that 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"' must
be over-riding 'xmlns="http://schemas.xmlsoap.org/wsdl/"'
because the URI is identical, but if I
remove 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"' the
XPATH still requires 'wsdl:message' instead of
simply 'message'.

If I change the default namespace
from 'xmlns="http://schemas.xmlsoap.org/wsdl/"' to
ANYTHING else I can drop the 'wsdl:'... and that blows my
mind.

What part of the header specifies that message is part
ofthe wsdl namespace? (It is if you look at the actual
schema at 'http://schemas.xmlsoap.org/wsdl/' but how does
the parser know that?)

Thanks,
--Doug


FRG

unread,
Mar 3, 2002, 6:46:22 AM3/3/02
to
XPath does not support the concept of a default namespace.
You MUST provide a binding to a prefix which idnetifes the
namespace to which your node(set) belongs. Remember
though, the prefix is just an arbritary set of characters
so it is perfectly o.k to bind a prefix of 'fred' in place
of 'wsdl', as in :-

m_dom.setProperty "SelectionNamespaces", "xmlns:fred='http:
//schemas.xmlsoap.org/wsdl/'

and then use :-

Set MessageList = m_dom.selectNodes("//fred:message")

If you don't like using prefix bindings you could always
use local-name() and namespace-uri() as in :-

Set MessageList = m_dom.selectNodes("//*[local-name()
='message' and namespace-uri()
='http://schemas.xmlsoap.org/wsdl/']")

You could even revert to using the default
SelectionLanguage of 'XSLPattern', but I wouldn't
recommend it !

Cheers

Fraser.

>.
>

0 new messages