Does "на" in this case mean really on top of the shelf? Or is it possible that the book is located somewhere in the middle as well, for example when there are several levels of free space in a shelf?
Yes, it could mean either of those (same as in English, right?)
It could be a number of possible answers. The book on a shelf; the book on the shelf; a book on a shelf; or a book on the shelf. Ukrainian isn't specific. Context might tell you which version would be the translated meaning. However, in Ukrainian it is 'book on shelf', as there is no definite or indefinite article. However, if you wanted to refer to a particular book, you would use 'це' to specify 'this book'.