Home › Forums › General XMetaL Discussion › get processing instruction node after xml declaration tag › Reply To: get processing instruction node after xml declaration tag
Reply to: get processing instruction node after xml declaration tagApril 5, 2012 at 7:22 pm
Here's a version that does what I suggested in item 1 from my initial reply:
var cwUtil = new ActiveXObject("CWUtil.StringUtil");
Application.MessageBox("Could not access cwUtil. Problem in On_Application_Before_Document_Open event.",48);
//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 = 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).