My goal is to generate a valid FODT document from an FODT template file and values passed from a bash script. More specifically I’d like to insert values into rows of a table with two columns. Rows should be added to the table depending on how many new items are being passed from the script.
My FODT template file contains a table with just one row:
<table:table table:name="table1" table:style-name="table1">
<table:table-column table:style-name="table1.A"/>
<table:table-column table:style-name="table1.B"/>
<table:table-row>
<table:table-cell table:style-name="table1.A1" office:value-type="string">
<text:p text:style-name="P3">First Column</text:p>
</table:table-cell>
<table:table-cell table:style-name="table1.B1" office:value-type="string">
<text:p text:style-name="P3">Second Column</text:p>
</table:table-cell>
</table:table-row>
</table:table>
From a first glance, the script should just generate additional table-row xml nodes with the respective values passed via the script.
Is there a best practice to achieve this result?
Intuitively, sed
would not be the first choice given its limitations handling the necessary newline and other special characters to generate XML code.