While doing a review, I saw this "first question" Creating simple citygml 3D models based on 2D shapefiles (alkis) shp2gml using Python?. To my surprise, the OP posted a first question with the sole purpose of sharing a (lengthy) solution he/she found after some research.
What's the appropriate action for this kind of questions?
I left a comment suggesting to post the solution as a self-answer. But I just wanted to check with the meta.