xquery doesn't support empty() function?

Hello,

In an other thread I read that someone get it to work (to use the emty()-function), but I can’t do it…
I get an error (function unknown: empty.)

I want to use a where clause like this:

where not(empty(input()/*[@doc_id=$a/@doc_id]/@author))

Isn’t it possible, or do I something wrong?

:wink:
Markus

Hi Markus,

no, Tamino in version 4.1 does not support the empty() function
use count() = 0 instead. Still your where clause seems strange
to me, maybe I’d understand if I saw the complete query.
An example that works for me is

for $b in input()//book
where count($b/author) = 0
return $b

in collection bookshop.

Regards,
Juliane.

Hi Juliane,

here is the complete query (with the use pf the emtpy function). Maybe you can find out, if it’s strange, and why :wink: ! Perhaps there is something to optimize…

The query’s aim is to get the last 100 modified documents (latest update_time attributes of the directory document) for all documents wich have an author attribute…

for $r in
(
for $d in input()/directory//doc_info[@update_time]
where not(empty(/[@doc_id=$d/@doc_id]/@author))
return $d
sort by (@update_time descending)
)
[position() > 0 and position() < 15]
return
($r)


[here is the original query for X-hive, that I want to adapt to Tamino:

let $b :=
(for $a in document(“/directory.xml”)/directory//doc_info[@update_time] sortby (./@update_time descending)
where not(empty(document(“/docs”)/
[@doc_id=$a/@doc_id]/@author))
return

{
string($a/@doc_id)
}

)
return
sublist($b, 1, 100)
]


THANKS in advance…
Markus

Hi Markus,

the original X-Hive query uses the document function to read
the directory and the docs info from two different XML files.
In Tamino you obviously represent the directory info by the
doctype ‘directory’. Where is the ‘docs’ info ?
I presume it is represented by a ‘docs’ doctype ?

Anyway, you can drop the first and the last two lines from
your query, just surround your FLWR in brackets and apply
a predicate.

The where clause selects those documents which are
mentioned in ‘docs’ and the respective element contains
an author attribute. Thus the where clause reads as
follows:

where count (input()/docs/*[@doc_id = $d/@doc_id]/@author) > 0

Regards,
Juliane.