Home Forums DITA and XMetaL Discussion setting modified attribute of revised element to last save date automatically Reply To: setting modified attribute of revised element to last save date automatically

Derek Read

Reply to: setting modified attribute of revised element to last save date automatically

A script similar to the following would probably do what you need:

[code]//XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
rng.MoveToDocumentStart();
if(rng.MoveToElement(“revised”)) {
var d = new Date;
rng.ContainerAttribute(“modified”) = d.toUTCString();
}[/code]

To get it to run at save you can put it into the appropriate events in a Startup MCR file. Note that as written this will run for all document types (not just DITA) so if that will be an issue for you additional checks would need to be implemented. For someone only working with DITA I'm pretty sure that should not be a problem. For someone working with other schemas that don't define an element named “revised” it should not be an issue either. Note that adding things to the system this way is fairly safe since we're not redefining any of the standard DITA behaviours (we're just doing something extra) but officially this type of change isn't really supported for the DITA authoring solution which is considered closed.

If you are running any 3rd party code with XMetaL Author Enterprise (other than our provided DITA solution or our integrations with Documentum or Sharepoint) be sure to check with the creator to see that this will not interfere with anything their code does. This would include CMS integrations but could include any other code provided to you that you add to the XMetaL Author Enterprise installation (either by hand or by running a 3rd party installer).

Here's what the MCR file might look like. Make sure you test it thoroughly before putting it into production as I have done only the very minimum, and of course can only test in my own environment.

[code]

function setRevisedModifiedDate() {
var rng = ActiveDocument.Range;
rng.MoveToDocumentStart();
if(rng.MoveToElement(“revised”)) {
var d = new Date;
rng.ContainerAttribute(“modified”) = d.toUTCString();
}
}
]]>

setRevisedModifiedDate();
]]>

setRevisedModifiedDate();
]]>

[/code]

Reply

Products
Downloads
Support