No, if you omit a prefix from an element name in an xpath, you tell the
xpath processor the element you want is in no namespace.

As far as I can tell, the prefix resolver is only called on the xpath (not
on nodes of the document).  So you might provide a prefix resolver extending
PrefixResolverDefault which knows the mappings of a certain set of prefixes
which you use in your xpath, and lets the default resolver's method handle
all others.

class MyPrefixResolver extends PrefixResolverDefault {
  private HashMap prefixes;
  public MyPrefixResolver(HashMap namespaceByPrefix, Node context) {
     super(context);
     prefixes = namespaceByPrefix;

  }

   public String getNamespaceForPrefix(prefix}{
        String ns = (String)prefixes.get(prefix);
        if (ns != null) return ns;
        return super(prefix);
  }

   etc. -- other methods as needed
}

You might have to use ugly prefixes to attempt to avoid clashes with
prefixes that might appear in a document created by someone else with
another namespace as their resolution.

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


>
> Hi Simon,
>
> ( Sorry if you got this more than once. Forgot to cc the list )
>
> I relalise I can do that ... but I would like NOT to specify the
> namespace in the XPath expression ( is that possible as per XPath
> specification? ).
>
> The reason is that the incoming SOAP message may have a different prefix
> for the same namespace.
> Furthermore, while PrefixResolver has a method called
> getNamespaceForPrefix(), it does not have a method called
> getPrefixForNamespace().
> If there was a method called getPrefixForNamespace()., then at least I
> could build the XPath expression by adding the prefix.
>
>
> Simon Kitching wrote:
>
> >Hi Jesus,
> >
> >
> >
> >><mm7:SubmitReq
xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL
-5-MM7-1-2">
> >><mm7:MM7Version>5.5.0</mm7:MM7Version>
> >><mm7:SenderIdentification>
> >> <mm7:VASPID>MIG</mm7:VASPID>
> >> <mm7:VASID>Mig-test4</mm7:VASID>
> >> <mm7:SenderAddress>
> >> <mm7:Number>+6140955555</mm7:Number>
> >> </mm7:SenderAddress>
> >></mm7:SenderIdentification>
> >>
> >>
> >>
> >
> >Have you tried
> >
> >
> >>    XPath xpath = new XPath(
"//SenderIdentification/SenderAddress/Number", this.locator, resolver,
XPath.SELECT );
> >>
> >>
> >XPath xpath = new
> >XPath("//mm7:SenderIdentification/mm7:SenderAddress/mm7:Number", ...); ?
> >
> >Regards,
> >
> >Simon
> >
> >
> >
> >
> >
>
>
> --
> Jesus M. Salvo Jr.
> Mobile Internet Group Pty Ltd
> (formerly Softgame International Pty Ltd)
> M: +61 409 126699
> T: +61 2 94604777
> F: +61 2 94603677
>
> PGP Public key:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC0BA5348
>
>
>

Reply via email to