General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Track Changes For Elements, Attributes, etc. In addition to Content

  • ada

    Track Changes For Elements, Attributes, etc. In addition to Content

    Participants 2
    Replies 3
    Last Activity 8 years, 3 months ago

    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 tag is changed to a , 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

    Reply

    Derek Read

    Reply to: Track Changes For Elements, Attributes, etc. In addition to Content

    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.

    Reply

    Derek Read

    Reply to: Track Changes For Elements, Attributes, etc. In addition to Content

    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]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;
    }
    ]]>
    [/code]

    Reply

    Derek Read

    Reply to: Track Changes For Elements, Attributes, etc. In addition to Content

    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.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support