How to use XSLT to modify a LibreOffice document at XML level?

I understand that LibreOffice document files (.odt, .ods, etc) are compressed archives containing multiple XML files internally. XSLT (Extensible Stylesheet Language Transformations) is a useful tool for modifying content marked up with XML. How do I use XSLT to modify a LibreOffice document at the XML level?

Why modify the XML internal files directly? I might want to restore a corrupted document as in question, “Table changed multiple cells to 0”, which is also bug 131025. I might want to fix other problems. I might want to generate document content programmatically. I am looking for advice on using XSLT which is useful for a range of tasks.

Is there some common XSLT structure which would make my work faster? Are there some tips about how to use XSLT effectively and safely on LibreOffice document content? Are there pitfalls I should watch out for? Where can I find documentation on the various files which make up a LibreOffice document?

Let’s assume that I know how to uncompress a LibreOffice document to get its XML internals, then make a new document from them. That is the subject of a different question.

Let’s assume that I know how to use XSLT transforms, and the xsltproc tool, on my computer. This question is about tips specific to the LO document structure, not XSLT in general.

I am not asking about using an XSLT filter to import data into Calc, or using XSLT via the LibreOffice application. This question is about modifying a LO document outside of the LibreOffice application.

You might want to have look at https://odftoolkit.org/

[Edit 2020-12-17] It contains the tool “ODF XSLT Runner”. Cite from the website, “ODF XSLT Runner is a small Java application that allows you to apply XSLT stylesheets to XML streams included in ODF packages without extracting them from the package.”

Thank you. The link is helpful. To make this answer useful to future people asking similar questions, it would be even more helpful to expand this answer with an explanation of what ODF Toolkit does and how it helps with what the question asks for.