You can bind the empty prefix to a namespace URI. Its often called the
'default namespace'.

e.g.

<foo xmlns="someURI">
    <bar/>
</foo>

In the above document the XPath expression /foo/bar will not work unless you
explicitly setup a NamespaceContext to set the default namespace URI to be
"someURI". If you map empty prefix, "", to "someURI" in your
NamespaceContext then /foo/bar will work.

An alternative approach which does not require a NamespaceContext but is way
ugly is

/*[local-name()='foo' and namespace-uri()='someURI']//*[local-name()='bar'
and namespace-uri()='someURI']/

James
----- Original Message -----
From: "Frank Sauer" <[EMAIL PROTECTED]>
To: "'bob mcwhirter'" <[EMAIL PROTECTED]>
Cc: "jaxen-interest" <[EMAIL PROTECTED]>
Sent: Friday, September 21, 2001 2:55 PM
Subject: [Jaxen] RE: some followup info


> Thanks! Can the label be an empty string?
> I find it very confusing that the xml file
> does NOT have any prefixes but I do have to
> specify one in the XPath expression....
> If the label is an empty string do I then have to
> write ':name', or just 'name'? I have to admit that I
> didn't study name spaces very much, but is there such
> a thing as a default namespace? And shouldn't the absence
> of a prefix translate to that default namespace?
>
> Frank Sauer
> The Technical Resource Connection, Inc.
> a wholly owned subsidiary of Perot Systems
> Tampa, FL
> http://www.trcinc.com
> -----------------------------------------------
> Java: The best argument for Smalltalk since C++
>
>
> -----Original Message-----
> From: bob mcwhirter [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 20, 2001 5:39 PM
> To: Frank Sauer
> Subject: Re: some followup info
>
>
> On Thu, 20 Sep 2001, Frank Sauer wrote:
>
> > Just found out that the taglib DTD contains this:
> >
> > <!ELEMENT taglib (tlibversion, jspversion?, shortname, uri?, info?,
tag+)
> >
> > <!ATTLIST taglib id ID #IMPLIED
> >   xmlns CDATA #FIXED
> > "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd";
> > >
> >
> > Could that be the culprit?
>
> Yah..
>
> You need to set up a NamespaceContext binding something
> (let's say "cheese") to that URL.
>
> Then, your XPath should look like:
>
> cheese:name/text()
>
> or similar.
>
> -bob
>
> _______________________________________________
> Jaxen-interest mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Reply via email to