pimcore-data-definitions
pimcore-data-definitions copied to clipboard
[Export] output property type in XML
| 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.
can you explain a bit more pls? the data-type comes from pimcore, so I don't quite get it.
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.
true, but where to get the type? Pimcore Class Definition would be the best place right?
I think so, yes.
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.
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
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.
ok then, PR?
ping @dkarlovi
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.
http://www.herongyang.com/XML/XSD-Statements-Embedded-in-XML-File.html
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