Xindice associates a namespace with prefix 'src' internally, as you can see
from the query result returned below, crams the namespace declaration into
every document you put into the database, and returns it in what is
extracted by queries.  The namespace is used for the attributes src:key and
src:col which specify the internal document identity and the collection from
which it was extracted (this allows you to get the whole doc easily later).
Xindice appears to put the declaration on extraction in the outermost
element returned from any document -- perhaps this is a bug and the
namespace declaration should be in the xapi:resource container element.
Xerces encounters first an attribute with name 'src' in the null namespace,
and, *in the same element*, the declaration of namespace prefix src.  That
declaration is of an attribute xmlns:src -- an attribute src in the
namespace with prefix xmlns. Now there are two attributes named src in the
same element, one with no prefix and one with prefix xmlns.  It is possible
that this is illegal according to the XML Namespaces spec (but I don't know
this for a fact).  It is also possible that it is a bug in Xerces.  In any
case, in the current implementation, the attribute name src is essentially
reserved to Xindice and cannot be used in documents, at least in any element
which also declares the Xindice internal namespace associated with the
prefix src.  You can work around it without breaking your other code by
changing the name on input to Xindice and changing it back (via XSLT or
something) after extraction.  I think there are fixes Xindice could make to
deal with this situation, but the developers will know better.

You might try getting a better interpretation from the namespace experts on
xml-dev.

Jeff

----- Original Message -----
From: "Dawid Weiss" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, April 27, 2002 12:30 AM
Subject: Name clashes.


>
> Hi.
>
> I  have  accidently  stumbled  upon  an  interesting  issue.  I have an
XML
> document with an element named "relation", which contains attributes "src"
> and "dst". The result of an XPath query returns this XML from Xindice:
>
> <?xml version="1.0"?>
> <xapi:resourceSet xapi:collectionURI="xmldb:xindice:///db/relations"
>                   xmlns:xapi="http://www.xmldb.org/xapi/ResourceSet";>
>         <xapi:resource xapi:documentID="7595167c">
>                 <relation rel_id="1"
>                         src="IOR%3A00..."
>                         dst="IOR%3A00..."
>                         xmlns:src="http://xml.apache.org/xindice/Query";
>                         src:col="/db/ophelia/tm/relations"
>                         src:key="7595167c" />
>         </xapi:resource>
> </xapi:resourceSet>
>
> It  seems  like  it's  a  valid XML, at least assuming the namespace may
be
> declared as an attribute inside the same element where it's used.
>
> Well, Xerces won't parse it. Neither 1.4.4, nor 2.0.1. The exception says:
>
> (2.0.1)
> Attribute "src" bound to namespace "null" was already
> specified for element "relation".
>
> (1.4.4)
> Attribute "xmlns:src"
> was already specified for element "relation".
>
> As  you can see in both cases the explanation of the exception, at least
to
> me, doesn't really explain anything...
>
> Do  you  think  it's Xerces's bug, or maybe I don't understand
something...
> M$ parses says this XML is a valid one.
>
> Cheers,
> Dawid
>
>
>

Reply via email to