It isn't clear what you want to do.
- Do you want to classify the book as above except if the book is PDF? Any other formats? What happens if a book has multiple formats?
- You don't want to classify if the book has one of a set of tags? Is that set subject to change?
- What happens if a book isn't classified?
- Does your classification template work (produce the wanted answer) for all books that should be classified?