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 Christian Gross <ma...@devspace.com> on 2002/12/31 20:29:57 UTC
A question regarding the output.
Hi
I have been playing more around with the Xindice database and the XMLRPC
interface.
COnsider the following query response.
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse><params>
<param>
<value>
<struct><member><name>result</name><value><?xml
version="1.0"?>
<result count="3"><doc
xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/test"
src:key="mydoc">something</doc><doc
xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/test"
src:key="mydoc2">another</doc><doc
xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/test"
src:key="mydoc3">something</doc></result></value></member>
</struct>
</value>
</param>
</params>
</methodResponse>
The output of this result is an XML document that has been XML encoded. It
sort of answers my question regarding the Insert document problem and the
requirement of having to use a CDATA section. However, the problem with
encoding is that if an XML proxy is used than a double encoding could
occur. This is because the & is a reserved character. Hence > will be
encoded to &gt; (I have had this problem in the past). This means
that a client program has to keep unencoding until it cannot unencoded no
more.
Could a CData section not be used? Or an embedded document or a DIME
attachment? I made some modifications to the expat parser to speed parse
an embedded XML document, without parsing the sub-nodes. It worked, but
these days a DIME attachment does basically the same thing.
Christian Gross
Software Engineering Consultant / Trainer
http://www.devspace.com
North America: 1-450-675-4208
Europe: +41.1.701.1166
Re: Output XML
Posted by Gul Akbar <G....@Bradford.ac.uk>.
Thank you Moran. That has answered my question perfectly.
Just one more thing, do you need the XPath to search the database, or could you
use the API to get some value from an element?
Thanks
Gul
Quoting moran@server.jce.ac.il:
> The reason that Xindice has allocated a unique identifier, is that
> you probably use a null value in the following command, when
> adding a document:
>
> XMLResource document = (XMLResource)
> col.createResource(null,"XMLResource");
>
> where createResource is defined by the API as follows:
> _______________________________________________________________
> public Resource createResource(java.lang.String id,
> java.lang.String type)
>
> Parameters:
> id - the unique id to associate with the created Resource.
> type - the Resource type to create
> _______________________________________________________________
>
>
> 1. What I suggest is using the name (or some other unique id) as the
> key.
> The key enables you a fast access when retrieving the documents.
>
> 2. It is possible to retrieve using Xpath by applying a query on the
> name
> you are searching... but thats less efficient.
>
> 3. to retrieve a document with the key simply use:
> public Resource getResource(java.lang.String id) as defined in the
> Collection API. The id in this case will be the name (or some other
> unique id).
>
> Note that a name is not realy a unique id, but that varies in
> implementations.
>
> Best,
> Moran.
>
>
> Quoting Gul Akbar <G....@Bradford.ac.uk>:
>
> > Hello,
> >
> > I have created a very simple XML Database for a Movie record. It takes
> the
> > format:
> >
> > <movie>
> > <name> Some Name </name>
> > </movie>
> >
> > In my searches, I always get some attributes in my <movie> tag, as can
> be
> > seen
> > below:
> >
> > <movie xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/movies"
> >
> > src:key="1a071f3e00fd295b000000f25c47fdc1">
> > <name> Some Name </name>
> > </movie>
> >
> > I have a few questions:
> >
> > * Is it possible to retrieve results without these?
> >
> > * I have noticed that the src:key has been allocated by Xindice as a
> unique
> >
> > identifier, is there a way to retrieve this in Java.
> >
> > * How would I store the <name> as a "primary key"?
> >
> > Thanking you in advance.
> > Gul
> >
> >
> > -------------------------------------------------
> > This mail sent through IMP: webmail.brad.ac.uk
> >
>
>
>
>
> -------------------------------------------------
> This mail sent through JCE IMP: http://portal.jce.ac.il/horde/
> Main Web Page http://www.jce.ac.il
>
-------------------------------------------------
This mail sent through IMP: webmail.brad.ac.uk
Re: Output XML
Posted by mo...@server.jce.ac.il.
The reason that Xindice has allocated a unique identifier, is that
you probably use a null value in the following command, when
adding a document:
XMLResource document = (XMLResource) col.createResource(null,"XMLResource");
where createResource is defined by the API as follows:
_______________________________________________________________
public Resource createResource(java.lang.String id,
java.lang.String type)
Parameters:
id - the unique id to associate with the created Resource.
type - the Resource type to create
_______________________________________________________________
1. What I suggest is using the name (or some other unique id) as the key.
The key enables you a fast access when retrieving the documents.
2. It is possible to retrieve using Xpath by applying a query on the name
you are searching... but thats less efficient.
3. to retrieve a document with the key simply use:
public Resource getResource(java.lang.String id) as defined in the
Collection API. The id in this case will be the name (or some other unique id).
Note that a name is not realy a unique id, but that varies in implementations.
Best,
Moran.
Quoting Gul Akbar <G....@Bradford.ac.uk>:
> Hello,
>
> I have created a very simple XML Database for a Movie record. It takes the
> format:
>
> <movie>
> <name> Some Name </name>
> </movie>
>
> In my searches, I always get some attributes in my <movie> tag, as can be
> seen
> below:
>
> <movie xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/movies"
>
> src:key="1a071f3e00fd295b000000f25c47fdc1">
> <name> Some Name </name>
> </movie>
>
> I have a few questions:
>
> * Is it possible to retrieve results without these?
>
> * I have noticed that the src:key has been allocated by Xindice as a unique
>
> identifier, is there a way to retrieve this in Java.
>
> * How would I store the <name> as a "primary key"?
>
> Thanking you in advance.
> Gul
>
>
> -------------------------------------------------
> This mail sent through IMP: webmail.brad.ac.uk
>
-------------------------------------------------
This mail sent through JCE IMP: http://portal.jce.ac.il/horde/
Main Web Page http://www.jce.ac.il
Output XML
Posted by Gul Akbar <G....@Bradford.ac.uk>.
Hello,
I have created a very simple XML Database for a Movie record. It takes the
format:
<movie>
<name> Some Name </name>
</movie>
In my searches, I always get some attributes in my <movie> tag, as can be seen
below:
<movie xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/movies"
src:key="1a071f3e00fd295b000000f25c47fdc1">
<name> Some Name </name>
</movie>
I have a few questions:
* Is it possible to retrieve results without these?
* I have noticed that the src:key has been allocated by Xindice as a unique
identifier, is there a way to retrieve this in Java.
* How would I store the <name> as a "primary key"?
Thanking you in advance.
Gul
-------------------------------------------------
This mail sent through IMP: webmail.brad.ac.uk