Okay I just figured out the NamespaceContext by poking around the javadocs a
bit more, but Bob beat me to a response.

So Bob - I'm trying to read through the specs to figure out why I can't
refer to an element using the prefix. The org.w3c.dom.Element.getName()
method doesn't change when I declare a namespace; in this case, it still
returns "xs:element". The various namespaces used seem like an unfortunate
bit of extra information I'm going to have to pass around, the code I'm
trying to change just has access to an Element and an xpath (String). I hate
to sound like a 2-year-old, but why do you need to know what the prefix
refers to? Isn't the node identified by the untranslated name?

-Matt

----- Original Message -----
From: "bob mcwhirter" <[EMAIL PROTECTED]>
To: "Matt Smith" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, April 29, 2002 10:30 PM
Subject: Re: [Jaxen] problem with namespaces?



Are you binding up a NamespaceContext somewhere?

The XPath needs to know what the 'xs:' prefix refers to.  It doesn't
pull it from the target document.  You need a NamespaceContext (or,
I think XPath has convenience methods for setting a namespace-prefix
mapping directly upon it).


-bob



On Mon, 29 Apr 2002, Matt Smith wrote:

> Hello all -
>
> I've been looking into Jaxen today because I was having performance
problems
> with XPathAPI. However, I've run into a problem where Jaxen returns on one
> of my xml schema documents, whereas XPathAPI does not. I assumed I was
doing
> something wrong, so I wrote some test cases and have it boiled down to
this:
>
> I have the following java snippet as a test (after loading a DOM Document)
>
>   XPath path = new DOMXPath("/xs:schema/xs:element']");
>   System.out.println(path.selectSingleNode(doc));
>
> which operates correctly and generates [xs:element: null] for the
following
> document:
> <xs:schema>
>     <xs:element/>
> </xs:schema>
>
> but which fails and outputs "null" for the following:
>
> <xs:schema xmlns:xs="foo">
>     <xs:element/>
> </xs:schema>
>
> Any reason that might be?
>
> Thanks,
> -Matt
>
>
> _______________________________________________
> Jaxen-interest mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest
>



_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to