----- Original Message -----
From: "Jesus M. Salvo Jr." <[EMAIL PROTECTED]>
To: "Jeff Greif" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, February 03, 2003 11:10 PM
Subject: Re: Namespace-aware XPath expression


> What the problem is I do not know in advance the prefix that may be used
> by a given namespace.
> All I know is that there will be two namespaces used,  the SOAP
> namespace and the MM7 namespace.
> Also, the same namespace could be used in a single XML document with
> different prefixes. Argh!
>
> So how do you specify an expression if you do not know in advance the
> namespace prefixes used in the document?

That's what I explained in my previous mail.  MyPrefixResolver gets a map
that looks like this {"__mm7__" -> "namespace1",
"__ns8__" ->"othernamespace", ...}.  You write your xpath using
/__mm7__:foo/__mm7__:bar without any regard for what prefixes are used in
the document.  The resolver resolves prefix __mm7__ to namespace1, which
will match to corresponding nodes from namespace1 in the document,
regardless of what prefix is used in the document.  The only way you'd be
messed up is if someone actually used __mm7__ in the document to refer to
some other namespace, which is why I suggested using unlikely prefixes in
the map and the xpath.

>
> Wouldn't it have been better if instead of the prefix as part of the
> expression, you instead use the namspace URI itslef is used?
> e.g.:
>
> //http:mynamespace.org:ElementA/http:yournamespace.org:ElementB/

Yes, IMHO it would be better to have a scheme like:
/{http://mynamespace.org}:eltA/{http://yournamespace.org}:eltB/...
if it could be made to work.  However, there are difficulties with the / and
: characters in the namespace uri getting confused with xpath syntax, and
many other problems.  That's why there are prefixes.  We're stuck with XPath
as it is.

>
>
> ... so you do not have to worry about prefixes in your xpath expression.
>
> Oh well.
>
>
>
>
>
>

Reply via email to