Applying styles to structured document

I want to pull some text from a database (e.g. a database of contacts that includes name, position, and a bio) and create a document that applies different styles to each text element automatically. Is there a way to do this?

I could imagine using a script to added markup tags around the different elements but then how to I tell LibreWrite to apply a particular style to the contents?

Thanks!

Have you read the section on mail merge in the Writer Guide?
Maybe check the chapter on styles f you aren’t up to speed with styles
Download Writer Guide from English documentation | LibreOffice Documentation - LibreOffice User Guides

Since you interact with a database, you can create a structured report with Base It has all tools in its report generator to do this. The report can be an .odt if you want to modify it later or a .pdf for direct printing or sending.