Reply to: Loading a documentMay 19, 2009 at 7:13 pm
I can think of a few possibilities, however, the product was not designed to do what you want to do so we are pushing the boundaries here (with the possibility that what you want is just not possible).
1) Modify the XML documents so that they are opened automatically as well-formed (using the method previously noted on this post). You could do this using a batch process of some kind (string find and replace, XSLT, or other means) using various 3rd party tools.
2) Create an application-level event macro called On_Application_Before_Document_Open. The script in this macro would open the file (using something like the Windows File System Object, ADODB.Stream, MSXML or another XML parser) to insert the PI (same as solution #1 above) into the document so that XMetaL will treat it as well-formed and standalone. Then it would save the document and allow the document open event to complete (by not setting the Application.CancelOpenDocument property). If you wish to remove this PI (no real reason unless other software you have objects to it, which it should not) you will then need to override the Save and SaveAs features to take care of writing out the document yourself as there is not way short of a script switching to PlainText view to remove a PI outside the root element of a document using the standard XMetaL APIs.
3) Add your own “Open Well Formed Document” feature. It may or may not be possible to detect if the document contains a SYSTEM or PUBLIC ID (and therefore bypass the dialogs you want to bypass) without doing this at the application level, similar to #2. It might be possible to create a similar On_Application_Before_Document_Open script that places the entire XML document in a string variable, then cancels the original open using Application.CancelOpenDocument, and instead opens the document using Documents.OpenString() with the boolWFEdit parameter set to true.
As I think more about this I think the easier option would be #3, though there might be even more possibilities.