XML Writer
Currently, Flow can only read XML, but we should start looking into saving XML files as well.
There are two libraries that could help us achieve that:
- https://github.com/veewee/xml
- https://github.com/saloonphp/xml-wrangler (this one operate son top of veewee/xml)
Before actual coding, we should first look into converting Rows into XML, we will need to figure out how to determine what should be saved as a value and what should be saved as an attributes.
Right now we are not able to implement veewee/xml package due to fact that it's using internally \DOMDocument class which cannot be serialized since PHP 8.1:
Exception: Serialization of 'DOMDocument' is not allowed, unless serialization methods are implemented in a subclass
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/Serializer/NativePHPSerializer.php:17
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/Serializer/CompressingSerializer.php:28
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/ETL/Cache/LocalFilesystemCache.php:50
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/ETL/Pipeline/CachingPipeline.php:67
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/ETL/DataFrame.php:739
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/ETL/DataFrame.php:774
Second library is unfortunately also not possible to use due to fact it internally uses package array-to-xml which requires to pass whole array of data at once.
Exception: Serialization of 'DOMDocument' is not allowed, unless serialization methods are implemented in a subclass
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/Serializer/NativePHPSerializer.php:17
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/Serializer/CompressingSerializer.php:28
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/ETL/Cache/LocalFilesystemCache.php:50
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/ETL/Pipeline/CachingPipeline.php:67
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/ETL/DataFrame.php:739
/Users/stloyd/Documents/flow/src/core/etl/src/Flow/ETL/DataFrame.php:774
This should be solvable by implementing custom serialization logic in XMLEntry::__serialize() and XMLEntry::__unserialize() methods().
XML should be dumped to string and then loaded from string during unserialization.
I wasn't even aware that DOMDocument is not serializable 🤦♂️
This task should be unblocked now due to #896
First attempt: https://github.com/flow-php/flow/pull/903