Home Forums General XMetaL Discussion get processing instruction node after xml declaration tag Reply To: get processing instruction node after xml declaration tag

Derek Read

Reply to: get processing instruction node after xml declaration tag

Here's a version that does what I suggested in item 1 from my initial reply:

try {
var cwUtil = new ActiveXObject("CWUtil.StringUtil");
}
catch(e) {
Application.MessageBox("Could not access cwUtil. Problem in On_Application_Before_Document_Open event.",48);
return;
}
//put file that is about to be opened into a string
//this works because the event this script is in runs before any of XMetaL's "open for edit" logic runs
var filepath = Application.OpenFileName;
var xmldoc = Application.FileToString(filepath);
//string replacement to find first occurrence of the PI in the doc, if there are more then a regex would be needed
var xmlnew = xmldoc.replace('','');
//write the new version of the file over top of the old one
//once that's done XMetaL should (in theory) open the modified version of the file
cwUtil.StringToUTF8File(xmlnew, filepath);
cwUtil = null;
} changeDCTMpi(); ]]>

I would do this over making changes to macros.mcr or any other additional application-level modifications. However, I still think the best place to handle this type of thing is in the CMS given that this appears to be a PI that Documentum is either setting or that it at least knows about.

I have not tested this with “XMetaL Author Enterprise for Documentum Webtop”.

Note that CWUtil is an undocumented control that ships with XMetaL Author Enterprise. Use with caution. As it is used here it could easily be replaced by the standard Windows FSO (File System Object).

Reply

Products
Downloads
Support