Pages: 1
Print
Author Topic: Track Changes For Elements, Attributes, etc. In addition to Content  (Read 2853 times)
ada
Member

Posts: 22


« on: July 08, 2014, 01:26:30 PM »

Hello,

We currently have XMetaL 6.0 Enterprise and the editors at our company are using track changes to track any content that has been changed. This is working great for us but we wanted to know if it is possible to extend that functionality so that we can also track changes to Elements or Attributes? So if say my <para> tag is changed to a <inline-para>, the editors would like to see that being changed. Is this possible through some type of macro and what would you think that would entitle? Let me know if you need any more information about how we have things setup in our environment.

Regards,
Ahmed
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: July 08, 2014, 03:20:09 PM »

Only insertions and deletions of elements are tracked.

Presumably what you are asking is to treat the change of one element to another (probably using the Element List) as a deletion followed by an insertion, or vice versa?

In theory that could be accomplished via script as there are APIs for all these functions. However, I'm not sure how much work that would entail or how well such a script could be written so that it works well with the existing UI. I'll have a look but can't really promise anything.
« Last Edit: July 08, 2014, 03:24:31 PM by Derek Read » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #2 on: July 08, 2014, 04:17:15 PM »

Here's something you can try adding to your document-level customization's MCR file.

I've only done basic testing on this so there are bound to be edge cases that this does not catch.
Make sure you test it thoroughly and make changes as needed (and remove the alerts I've put in here to aid with understanding the logic).

Code: (example)
<MACRO name="On_ElementList_Change" lang="JScript" hide="false"><![CDATA[
var elemChangeTo = Application.ElementList.SelectedName;
var rng = ActiveDocument.Range;
if(ActiveDocument.TrackRevisions) { //override default behaviour when Revision Tracking is enabled
Application.Alert("change tracking is on");
if (rng.CanChange(elemChangeTo)) { //<--safety check in case the change is not allowed for some unforeseen reason
Application.Alert("doing the special change");
//the change is allowed, do the override
rng.SelectElement();
var elemStr = rng.Text;
rng.Delete();
rng.PasteString(elemStr);
}
else {
//the change is not allowed
Application.Alert("Cannot change element to '" + elemChangeTo + "'.");
}
}
else {
Application.Alert("change tracking is off, doing default behaviour");
//do the default behaviour when Revision Tracking is disabled
rng.ContainerName = elemChangeTo;
}
]]></MACRO>
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #3 on: July 08, 2014, 04:19:15 PM »

To make this work for all document types you could add it to an application-level MCR file, but in that case you need to use a different event named "On_Application_ElementList_Change". The logic would likely be the same unless there are specific edge cases you need to deal with for a specific document type.
Logged
Pages: 1
Print
Jump to:  

email us