Hi @vvoona, this is a possible expression, assuming that the variable $doc stores the source XML document.
for $id in distinct-values($doc//id/text()) where 1 < count($doc//id[text() = $id]) return $doc//book[data(id) = $id and normalize-space(data(status)) = 'published']