Thanks, but don't think this helps.

The problem is that i need a function like

declare function t:getIdByName($arg)
{
  let $x := collection($dbName)/module//object[@name = $arg]
  return if( empty($x/@id) ) then "-1" else $x/@id
};

But as I understand, BaseX doesn't have runtime query optimization, that's why this variant works too long. I thought, indexes could help to solve this problem.

2012/6/4 Christian Grün <christian.gruen@gmail.com>
Hi Alex,

> but how can I get objects in my data base that contain these indexes?

just use ordinary XPath/XQuery expressions, such as..

 db:open('db')//*[@* = 'id152429']

You can also directly retrieve text and attribute nodes, e.g. as follows [1]:

 db:attribute('db', 'id152429')

Hope this helps,
Christian

[1] http://docs.basex.org/wiki/Database_Module#db:attribute