Let's say I have a document of the form
<document>
<!-- document properties, not versioned -->
<properties>
<created>2014-01-01</created>
<modified>2014-01-02</modified>
<version>3</version>
<!-- ... -->
</properties>
<!-- items list, versioned -->
<items>
<item name="item1">...</item>
<item name="item2">...</item>
<item name="item3">...</item>
</item>
</document>
Is there a method of internally versioning the items data so I could create an API which could load the document for a given version, say with pseudocode
document.load("example.xml", version=2)
foreach(item in document.items) { .. }
This might load the document so that the items list only includes item1 and item2 because item3 had not yet been added in version 2.
My first thought is to simply record a "regeneration" process as a part of the document itself, such as
...
<versioning>
<version id="1">
<add name="item1"/>
<add name="item2"/>
</version>
<version id="3">
<add name="item3"/>
<update name="item1" property="example" value="true"/>
</version>
<version id="4">
<remove name="item2"/>
<remove name="item3"/>
</version>
</versioning>
...
and the pseudocode load() method above would simply step through each version's commands up to and including the target version.
No comments:
Post a Comment