Hi Gul,

Glad I could help.

No exception will be thrown because if you add the document with out a
user generated key then xinidce generates a unquie key for the document.
But if you add the same document with the same name then xindice just
overwrites the old document with the new document.

Todd
On Fri, 2002-12-06 at 16:19, Gul Akbar wrote:
> I have found what my problem is. It is to do with my servlet and NOT Xindice.
> I call the method which adds the record to the database TWICE. So basically 
> there are two records stored in the database.
> 
> Is there a way in which Xindice reports an exception if the same records is 
> being added twice; i.e. primary key in relational databases?
> 
> Thanks for your help
> Gul
> 
> 
> 
> Quoting Gul Akbar <[EMAIL PROTECTED]>:
> 
> > Todd,
> > 
> > I actually use a Java servlet to access the database. The code below is
> > what I 
> > used (I found this code on the website):
> > 
> > -----------------------------------
> > Collection col = null;
> > 
> > try {
> >  String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
> >  Class c = Class.forName(driver);
> > 
> >  Database database = (Database) c.newInstance();
> >  DatabaseManager.registerDatabase(database);
> >  col = DatabaseManager.getCollection("xmldb:xindice:///db/phonebook");
> > 
> >  String xpath = "//phonebook[name='Tom' and number='07989270142']";
> > 
> > 
> >  XPathQueryService service = (XPathQueryService) col.getService
> > ("XPathQueryService", "1.0");
> >  ResourceSet resultSet = service.query(xpath);
> >  ResourceIterator results = resultSet.getIterator();
> > 
> >  while (results.hasMoreResources()) {
> >    Resource res = results.nextResource();
> >    String outcome = (String) res.getContent();
> >    System.out.println(outcome)
> >    }//while
> > 
> > }//try
> > catch (XMLDBException e) {
> >  System.err.println("XML:DB Exception occured " + e.getMessage());
> >  }//catch
> > catch (Exception ie) {
> >  System.err.println("XML:DB Exception occured " + ie.getMessage());
> >  }//catch
> > 
> > -----------------------------------
> > 
> > I use this in a class which my servlet calls. It works fine in some
> > respect. I 
> > can search for everything in the database, and it returns null if no
> > records 
> > have been found. However, using the OR operator, it returns the same
> > record 
> > twice.
> > Can you see what the problem might be?
> > 
> > 
> > Thanks
> > Gul
> > 
> > 
> > 
> > 
> > Quoting Todd Byrne <[EMAIL PROTECTED]>:
> > 
> > > Hi Gul,
> > > 
> > > I ran your query from the command line on your sample document in a
> > > test
> > > database and it only returned one record like I expected.  Are you
> > > sure
> > > this record isn't in more then one document or repeated in your
> > > document?
> > > 
> > > here is the command I ran: xindice xpath -c /db/test -q
> > > "//phonebook[name='Tom' or number='07989270142']"
> > > 
> > > and my output:
> > > <?xml version="1.0"?>
> > > <phonebook xmlns:src="http://xml.apache.org/xindice/Query";
> > > src:col="/db/test" src:key="test">
> > > <name>Tom</name>
> > > <number>07989270142</number>
> > > </phonebook>
> > > 
> > > I am using version 1.0 still.  
> > > 
> > > Maybe you can discribe your problem in a tad more depth and I would
> > be
> > > glad to continue to help.
> > > 
> > > Todd Byrne
> > > 
> > > On Thu, 2002-12-05 at 09:58, Gul Akbar wrote:
> > > > Hello,
> > > > 
> > > > I have this problem with my XPath Query.
> > > > 
> > > > //phonebook[ name='Tom' or number='07989270142' ]
> > > > 
> > > > This returns the same record twice, and I know that there is only
> > one
> > > of those 
> > > > records. The XML that is stored:
> > > > 
> > > > <phonebook>
> > > > <name>Tom</name>
> > > > <number>07989270142</number>
> > > > </phonebook>
> > > > 
> > > > Can anyone please tell me why this record is being returned twice
> > when
> > > I use 
> > > > the boolean operator "OR" (shown in the XPATH above).
> > > > 
> > > > Thanking you in advance
> > > > Gul
> > > > 
> > > > -------------------------------------------------
> > > > This mail sent through IMP: webmail.brad.ac.uk
> > > 
> > > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -------------------------------------------------
> > This mail sent through IMP: webmail.brad.ac.uk
> > 
> 
> 
> 
> 
> 
> 
> -------------------------------------------------
> This mail sent through IMP: webmail.brad.ac.uk

Reply via email to