You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Vadim Gritsenko <va...@reverycodes.com> on 2004/05/20 14:33:01 UTC
Re: default namespace problems
Murray Altheim wrote:
> Vadim Gritsenko wrote:
>
>> Steven Shand wrote:
>>
>>
>>> Hi,
>>>
>>> I'm having some issues searching documents within a default namespace.
>>>
>>> if my document looks like
>>>
>>> <node1 xmlns="http://foo.bar.com" >
>>> <bar>content</bar>
>>> </node1>
>>>
>>> I'd assume that I would do service.setNamespace( "",
>>> "xmlns="http://foo.bar.com" )
>>>
>>> or even
>>>
>>> service.setNamespace( null, "xmlns="http://foo.bar.com" )
>>>
>>> neither of these work.
>>> However if I add a prefix to my document like:
>>>
>>> <foo:node1 xmlns:foo="http://foo.bar.com" >
>>> <foo:bar>content</foo:bar>
>>> </foo:node1>
>>>
>>> and do service.setNamespace( "foo", "xmlns="http://foo.bar.com" )
>>>
>>> my query works fine. Unfortunately this isn't a solution for me.
>>
You are right and service.setNamespace( "", "...") does not work, but
you don't have to change your document to perform a query - namespace
prefix in the document and namespace prefix in the query does not have
to match. Just use any non-empty prefix in your query (like 'foo'), and
it will work (see my other email with simple example).
Vadim