flow icon indicating copy to clipboard operation
flow copied to clipboard

XML Writer

Open norberttech opened this issue 2 years ago • 4 comments

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.

norberttech avatar Nov 05 '23 13:11 norberttech

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.

stloyd avatar Dec 30 '23 18:12 stloyd

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 🤦‍♂️

norberttech avatar Dec 31 '23 13:12 norberttech

This task should be unblocked now due to #896

norberttech avatar Jan 01 '24 10:01 norberttech

First attempt: https://github.com/flow-php/flow/pull/903

norberttech avatar Jan 18 '24 17:01 norberttech