Orckestra / C1-CMS-Foundation

C1 CMS Foundation - .NET based, open source and a bundle of joy!
https://c1.orckestra.com/
Other
250 stars 109 forks source link

XmlDataProvider - preserve xml field values in not encoded format #268

Open napernik opened 8 years ago

napernik commented 8 years ago

At the moment XmlDataProvider encodes xml fields, which makes it hard to

1) read/copy/manually modify it when needed 2) see the diffs in the case the file is version controlled

Example:

<PagePlaceholderContentElements PublicationStatus="published" ChangeDate="2015-09-29T12:56:21.5674048+02:00" ChangedBy="admin" PageId="3a613405-9990-47a6-8f00-672a8e6de9e7" PlaceHolderId="start" Content="&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&#xA;&#x9;&lt;head&gt;&#xA;&#x9;&lt;/head&gt;&#xA;&#x9;&lt;body&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&lt;f:function name=&quot;Composite.Web.Html.Template.PageTemplateFeature&quot; xmlns:f=&quot;http://www.composite.net/ns/function/1.0&quot;&gt;&#xA;&#x9;&#x9;&#x9;&lt;f:param name=&quot;FeatureName&quot; value=&quot;Content Start&quot; /&gt;&#xA;&#x9;&#x9;&lt;/f:function&gt;&#xA;&#x9;&lt;/body&gt;&#xA;&lt;/html&gt;" SourceCultureName="en-US" />

Suggested format:

<row PublicationStatus="published" ChangeDate="2015-09-29T12:56:21.5674048+02:00" ChangedBy="admin" PageId="3a613405-9990-47a6-8f00-672a8e6de9e7" PlaceHolderId="start" SourceCultureName="en-US">
<fld n="Content">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    </head>
    <body>
        <f:function name="Composite.Web.Html.Template.PageTemplateFeature" xmlns:f="http://www.composite.net/ns/function/1.0">
            <f:param name="FeatureName" value="Content Start" />
        </f:function>
    </body>
</html>
</fld>
</row>            
burningice2866 commented 8 years ago

Wouldn't that make the parsing of Datastores more memory consuming, since the Content is now treated as XElement's, instead of a simple string?

And how would you know if a Content-property contains actual xml or just text or base64 encoded binary data?

napernik commented 8 years ago

And how would you know if a Content-property contains actual xml or just text or base64 encoded binary data?

We can f.e. introduce an extra attribute for that, when it is present, the provider would attempt to save the field in an xml friendly way.

Wouldn't that make the parsing of Datastores more memory consuming, since the Content is now treated as XElement's, instead of a simple string?

It is not necessarily a significant difference to use some extra CPU/memory compare to the actual time writing to file system. On the upside, the file sizes could actually be a bit smaller, as there won't be a need to encode all the characters.

burningice2866 commented 8 years ago

Yet another attribute :) Looking at how EF does it, best would be to introduce a new StoreFieldType ala [StoreFieldType(PhysicalStoreFieldType.Xml)]

The SQL dataprovider would then also use the XML datatype for the table column, as MS SQL supports xml as a native type.