جَاءَ ذُو عِلْمٍ.
Translation: A person of knowledge came.
ذُو: nominative subject marked by wāw, the first term of iḍāfa; عِلْمٍ: genitive second term.
هٰذَا كِتَابٌ.
Translation: This is a book. Here «هٰذَا» is a demonstrative.
Avoid confusion: «ذَا» may be the accusative form of ذُو, meaning “possessor of”; do not classify every occurrence of «ذا» as the same grammatical item.