Home Forums General XMetaL Discussion Xmetal hangs/crashes on ActiveDocument.Reload() Reply To: Xmetal hangs/crashes on ActiveDocument.Reload()

Derek Read

Reply to: Xmetal hangs/crashes on ActiveDocument.Reload()

I assume your DOCTYPE decl looks something like the following (as recommended by W3C for use on the web):

Catalog files work as you would expect in XMetaL Author (and as documented) and don't require any special code to be created for normal use. However, in this case they never come into play because the SYSTEM id value above points to a DTD that is present (the W3C actually hosts a copy there) and so XMetaL 'helpfully' downloads it for you and uses that copy. In cases where a company owns that location they can put a CSS, CTM and MCR file with the same name as the DTD there (or an XAC file) and XMetaL will download and use them, giving you a fully functioning XMetaL customization. I wouldn't generally recommend it (for reasons including the fact that it might be slow and adds the complexity of managing a web server) but the feature exists for that reason. It works the same for XSD files.

The PUBLIC id value is only used when XMetaL determines that there is no file located at the path specified in the SYSTEM id (the second quoted section in the DOCTYPE decl). The diagram on page 8 in this set of slides shows the logic: http://www.slideshare.net/XMetaL/deploying-schemas-and-xmetal-customization-files

XMetaL will probably wait forever for the DTD to arrive as long as it has been told (in this case by the W3.org server) that it is going to get something. If the server doesn't offer it up or it takes a long time to do so that could look like the software is frozen. It is up to the W3.org website in this case. After downloading, the file will be placed in your Windows account's “temp” folder somewhere similar to the following (if you look at “temp” you will see lots of junk in there from many different apps):
C:Documents and SettingsLocal SettingsTemphttp://www.w3.orgTRxhtml1DTD

To find the exact location of the DTD after download you can use this API:
//XMetaL Script Language JScript:

Right now it looks like it takes between 5 and 10 minutes for the W3.org website to serve up this DTD when requested (tested with both XMetaL and several different web browsers). Keep in mind that there are 4 files involved (the DTD and 3 ENT files that it references).

Having said all of that, I'm not sure about ActiveDocument.Reload() and any crashes you are seeing. However, calling that API causes XMetaL to reload the XML file from disk, and the whole process is pretty much identical to you closing the file and then reopening it, except that in this can the API doesn't care if the file has not been saved or if any changes were made to it, those are all just thrown away. The whole document is validated upon opening however, and customization files should be reloaded. I doubt that API has ever been stress tested to any degree, and it may not really be designed to work with DTDs not located on your local system (not sure).

It sounds like your real issue is that you want XMetaL to use your local copy of the DTD. Anyone customizing XMetaL really doesn't want their DTD to be downloaded from a server they have no control over and have a customization be autogenerated. You want to control which DTD is being used so you can specify your own CSS, CTM and possibly MCR code.

The easiest thing to do in this case is to change the DOCTYPE declaration. In most cases the XML file you are editing with XMetaL is not in its final form and almost always needs to be transformed to some other format for final consumption. XHTML is a special case because it can be used as the final format so changing the DOCTYPE might seem like adding some unecessary complexity to things, however, it is really the browser (or W3C) that wants the DOCTYPE in that final format. One simple change to the file as an XSLT transform would do that. The alternative would be to add a “Save for Web” macro that would take ActiveDocument.Xml and append it to the desired and maybe even remove the XML declaration. That would be a very simple script to write but you'd probably need to use FSO to write out the file since XMetaL's own APIs won't let you mess with the DOCTYPE or remove the XML declaration.

The alternative would be to leave the XML declaration alone but get XMetaL to use your local copy of the DTD. An application-level macro should let you do that. Something like this:

if (Application.ResolveEntityInfo.systemID == "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd") {
Application.ResolveEntityInfo.systemID = "C:\my_xmetal_customizations\xhtml\xhtml1-strict.dtd";