Verify References in a Ditamap - ExtendScript
Hi Folks,
I wrote a script to verify if all the files referenced in a ditamap exist. The script is rather slow when the a ditamap refers to other ditamaps because the script opens those ditamaps.
var doc = app.FirstOpenDoc;
CheckDITATopicref(doc)
function CheckDITATopicref(doc) {
var DITATopicref = doc.FirstDITATopicrefElementInDoc;
while(DITATopicref.ObjectValid()) {
var myFile = new File(DITATopicref.TopicRefAbsoluteFilePath);
if (!(myFile.exists)) {
$.writeln("The following file is missing: "+ DITATopicref.TopicRefAbsoluteFilePath)
} else {
if(DITATopicref.TopicRefAbsoluteFilePath.split(".")[DITATopicref.TopicRefAbsoluteFilePath.split(".").length-1] == "ditamap"){ //if file is ditamap
var Topicref = Open(DITATopicref.TopicRefAbsoluteFilePath, GetOpenDefaultParams (), new PropVals());
CheckDITATopicref (Topicref)
Topicref.Close(Constants.FF_CLOSE_MODIFIED);
}
}
DITATopicref = DITATopicref.NextDITATopicrefElementInDoc;
}
}
I'm wondering if there are faster methods.
- Is opening the ditamap mandatory to do the verification?
- Do I need to loop through the topicrefs to find the missing ones?
Regards
