重构 TClient 数据集
能否在不丢失数据的情况下重构 TClientDataSet XML 文件? 是否有任何演示应用程序或源代码可以展示如何进行此类重组?
Can a TClientDataSet XML file be restructured without losing data? Are there any demo applications or source code that shows how to do such a restructure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是和否,xml 文档是使用 XLST 进行转换的,因此它需要符合该模板才能被 TClientDataSet 读取。
然而,这也意味着您还可以将文档转换为您喜欢的任何格式到单独的文档中,只是不能将转换后的文档直接加载到 TClientDataSet 中。
编辑:
糟糕,忘记发布示例了。
Code Central 上的此项目展示了从 clientdataset 到 ADO 记录集的转换。
yes and no, the xml doc is transformed using XLST so it needs to conform to that template to be able to be read by the TClientDataSet.
However that does also mean that you can also transform the doc to any format you like yourself into a separate doc, you just can't load the transformed doc directly into the TClientDataSet.
EDIT:
Oops, forgot to post an example.
This project on code central shows a transform from clientdataset to an ADO recordset.
为了更改磁盘上的 CDS 结构,我使用了下面概述的子类。 我们以二进制格式将数据写入流(在压缩/加密之前),但它对于 XML 格式的工作原理应该大致相同。
如果您需要从保存的数据集中添加/删除任何字段或更改字段定义,则只需增加数据集表版本即可。 每次打开数据集时,它都会将保存的版本号与当前版本号进行比较。 如果保存的表是旧的,它将被复制到新的结构中,因此,如果您需要进行更改,第一次重新加载该表时,性能将会受到影响,但之后它应该像往常一样从磁盘加载。
因此,如果您在合并后将 CDS 保存回磁盘 - 瞧 - 您的 XML 结构就会以 CDS 友好的格式更新。
In order to make changes to CDS structure on disk I used a sub-class outlined below. We write our data in binary format to a stream (before compression/encryption) but it should work much the same for XML format.
If you need to add/remove any fields from your saved dataset or change the field definitions then you just increment the dataset table version. When the dataset is opened each time it compares the saved version number with the current. If the saved table is old it will be copied into the new structure, so if you need to make changes, you will take one performance hit the first time you reload the table, but after that it should load from disk as usual.
So, if you save the CDS back to disk after doing the merge - voila - your XML structure is updated, in a CDS friendly format.