Project

General

Profile

Feature #6938

XML seriliazation improvement

Added by Igor Skornyakov over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
11/16/2022
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD

Related issues

Related to Database - Feature #6453: temp-table features Closed

History

#1 Updated by Igor Skornyakov over 1 year ago

#2 Updated by Igor Skornyakov over 1 year ago

At this moment the XMLExport class uses manual formatting of the document based on indent()/leneBreak() calls (if formatting is required). In addition, it uses writeStartElement/writeEndElement calls and code blocks to ensure the correct matching of these calls.
As a result, the code is quite verbose and is difficult to maintain.

Why not extend XMLStreamWriter so that it will care about indentation itself? This will reduce the number of indent()/leneBreak() calls and indent level adjustments dramatically. After all, these actions are required only on writeStartElement/writeEndElement calls.

To ensure that elements are properly nested/closed we can add a single method public void writeElement(String name, ElementBuilder elementBuilder) where ElementBuilder is a functional interface with a single method (public void build()).
After that, we can refactor the code moving the logic between writeStartElement and writeEndElement calls into a lambda expression and passing it to the writeElement.
I believe that it will be much less error-prone than the current approach base just on the code formatting because the compiler will validate the document structure.

Also available in: Atom PDF