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 António Santos <an...@fe.up.pt> on 2003/06/04 13:48:23 UTC
Setting attribute as index
Hi all,
I tried to figure out how to do this on the archives and other tutorials, but
I'm stuck with this.
I want to set an attribute ("Id") as the index for a collection.
The XML documents all have an "Id" attribute and I want to make XIndice to put
the auto-generated key on that attribute.
I tried the add_indexer command but it doesn't work as I want (it actually
removes the attribute).
Any clue,
Thanks,
Antonio Santos
RE: Setting Id attribute with XIndice's auto-generated ID
Posted by Kevin Ross <Ke...@iVerticalLeap.com>.
I do it a little differently using my own id generator, where I specify
the documentId, and the documentId is also set as the content's @id.
XMLResource xmlResource =
(XMLResource)collection.createResource(documentId,
XMLResource.RESOURCE_TYPE);
// now store the document
xmlResource.setContentAsDOM(content.getNode());
collection.storeResource(xmlResource);
For your particular case, you might try something like this, but I'm not
sure it works:
XMLResource xmlResource =
(XMLResource)collection.createResource(XMLResource.RESOURCE_TYPE);
// set the id generated from xindice on the doc
// pseudo code: content.setAttribute("id", xmlResource.getDocumentId())
// now store the document
xmlResource.setContentAsDOM(content.getNode());
collection.storeResource(xmlResource);
-Kevin Ross
-----Original Message-----
From: António Santos [mailto:ansantos@fe.up.pt]
Sent: Wednesday, June 11, 2003 1:04 PM
To: xindice-users@xml.apache.org
Subject: Setting Id attribute with XIndice's auto-generated ID
Hi all,
A few days ago I posted here a question on how to set an element's
attribute
as an index with the auto-generated IDs. Since noone replied, I'm now
reformulating the question.
All my XML documents have an Id attribute in the root element. When I
send one
of these XML documents to XIndice (to store it), that Id attribute is
still
empty and I want XIndice to fill that attribute automatically with the
auto-generated ID, and then store the document. Is that possible? If so,
how
can I do that? And then, how to set that attribute as the index for that
collection?
Anyone?
Thanks,
Antonio Santos