Issue #328 exposed that certain characters in an XML label go un-escaped into a Jinja2 page template that generates a JSON file. The fix was simple enough: escape " characters before they go into a page template.
However, this exposes a weakness in the architecture of the program: using templates. Templates are a convenience and when generating flexible and forgiving text formats (such as HTML) they're generally safe and effective. However, for more rigid formats like JSON (or even XML), the simple string-substitution of templates can create constructs that are invalid, as #328 demonstrated.
Using serialization as opposed to templates bypasses this problem entirely. Instead of substituting values into DOI_IAD2_template_20210914-jinja2.json, DOI_IAD2_template_20210914-jinja2.xml, and DOI_DataCite_template_20210520-jinja2.json, this program should create the data structures they represent in memory and then simply use JSON and XML serialization to consistently create correct culminations.
💡 Description
Issue #328 exposed that certain characters in an XML label go un-escaped into a Jinja2 page template that generates a JSON file. The fix was simple enough: escape
"
characters before they go into a page template.However, this exposes a weakness in the architecture of the program: using templates. Templates are a convenience and when generating flexible and forgiving text formats (such as HTML) they're generally safe and effective. However, for more rigid formats like JSON (or even XML), the simple string-substitution of templates can create constructs that are invalid, as #328 demonstrated.
Using serialization as opposed to templates bypasses this problem entirely. Instead of substituting values into
DOI_IAD2_template_20210914-jinja2.json
,DOI_IAD2_template_20210914-jinja2.xml
, andDOI_DataCite_template_20210520-jinja2.json
, this program should create the data structures they represent in memory and then simply use JSON and XML serialization to consistently create correct culminations.