Well: both of those XML documents are malformed. And describing the second document as "hierarchical" is extremely misleading; the only reason it looks hierarchical is that it has misleading indentation which makes it look hierarchical. In reality every element is a child of the root "geo" element so it's as flat as flat can be. The first document, which you call "flat", is more hierarchical than that.
Anyway, about that XSLT: the way to design such as thing is to state in advance how an element in the source document should be converted to an element in the target document. It's pretty clear that a <Geo> element in the source should be converted to a <geo> element in the target. What are the other rules? (Hint: I'm not asking you about XSLT code there, I'm asking about the rules.)