pimcore-data-definitions icon indicating copy to clipboard operation
pimcore-data-definitions copied to clipboard

[Export] output property type in XML

Open dkarlovi opened this issue 6 years ago • 12 comments
trafficstars

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Branch? master

Specify property type (like text, int or similar) to allow not losing information when importing.

dkarlovi avatar Nov 21 '18 11:11 dkarlovi

can you explain a bit more pls? the data-type comes from pimcore, so I don't quite get it.

dpfaffenbauer avatar Nov 21 '18 13:11 dpfaffenbauer

If you export and plan to import somewhere else, it's vital to keep the whole semantics

For example,

<property></property>

Is that meant to be bool(false), string(0) "", int(0) or NULL?

Having

<property type="string"></property>

removes that doubt.

dkarlovi avatar Nov 21 '18 13:11 dkarlovi

true, but where to get the type? Pimcore Class Definition would be the best place right?

dpfaffenbauer avatar Nov 21 '18 13:11 dpfaffenbauer

I think so, yes.

dkarlovi avatar Nov 21 '18 13:11 dkarlovi

Also, maybe we can just export gettype($value)? Since the type will be determined by the interpreters too, not directly related to Pimcore's type.

dkarlovi avatar Nov 21 '18 14:11 dkarlovi

yes, but some could be null, some could be array for the same property, since pimcore sometimes returns null for empty arrays. I think we should just use this: https://github.com/pimcore/pimcore/blob/master/models/DataObject/ClassDefinition/Data.php#L499

dpfaffenbauer avatar Nov 21 '18 14:11 dpfaffenbauer

Yes, but you might have transformed an array to a string by fetching only the first element? Also, some mappings will not have an "origin" (custom props).

The idea here is to keep the original data's type as it was serialized to XML. I think checking the final type should be good enough and cover almost all cases.

dkarlovi avatar Nov 21 '18 14:11 dkarlovi

ok then, PR?

dpfaffenbauer avatar Nov 21 '18 14:11 dpfaffenbauer

ping @dkarlovi

dpfaffenbauer avatar Dec 17 '18 14:12 dpfaffenbauer

Probably best to use a standards based solution like adding xsi:nil for null, etc.

We talked about adding an inline schema to enable the user to validate the file, this might be connected.

dkarlovi avatar Dec 17 '18 15:12 dkarlovi

http://www.herongyang.com/XML/XSD-Statements-Embedded-in-XML-File.html

dkarlovi avatar Feb 20 '19 13:02 dkarlovi

So, this would add a XML Schema instance namespace like this

<export xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <property xsi:type="xsd:boolean">true</property>
</export>

https://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions

dkarlovi avatar Apr 26 '19 06:04 dkarlovi