1. How does the generation of the sitemap.xml works, how the urls are retrieved?
If sitemap.xml is not created in database or sitemap.xml is older then last 12 hours from current date and time then odoo logic will retrieve all the website page and it will generate new sitemap.xml. https://github.com/odoo/odoo/blob/10.0/addons/website/controllers/main.py#L160
Odoo will retrieve all the website pages using website page enumerate_pages. (https://github.com/odoo/odoo/blob/11.0/addons/website/models/website.py#L443)
2. How often will Odoo re-generate the sitemap.xml?
Odoo will check if sitemap created in database in last 12 hours then it will return this sitemap.
If sitemap is older then last 12 hours from now then odoo will generate new sitemap in database.
3. Why would the generation of /sitemap.xml access the content of the template while it seems do not touch any content in the template?
https://github.com/odoo/odoo/blob/11.0/addons/website/models/website.py#L504You can see during build I think it try to build all templates and give error ? That is our assumption.