DITA and XMetaL Discussion

XMetaL Community Forum DITA and XMetaL Discussion Opening XHTML file in Xmetal from map

  • gcrews

    Opening XHTML file in Xmetal from map

    Participants 1
    Replies 2
    Last Activity 10 years, 1 month ago

    How can I get XHTML files to open in XMetaL that are linked in a ditamap? If .html files are associated with IE then they open fine in IE when you double click them in in Xmetal. If I set the default program for .html to Xmetal (witch isn’t the best solution) and I double click on on in a map in XMetaL, XMetaL says “This file does not have a program associated with it for performing this action…” despt it opening fine from Explore in Xmetal.

    Reply

    Derek Read

    Reply to: Opening XHTML file in Xmetal from map

    No solution for you, but I'm looking into it. Microsoft has me stumped here so far.


    I can reproduce something like this on one of my machines and I think it is your issue. No matter what “normal” steps I do to associate opening .html files with an application (any application) the files still open in IE.  “Normal” here means using Windows Explorer to associate file extensions, not hand editing the registry.

    The mysterious thing is that our code simply asks Windows to “shell execute” the file, passing it the “open” action. This lets Windows decide which application should do the open and I would expect that to function exactly the same as if you double click on a file in Windows Explorer.

    The actual code is as follows (the relevant line is the “ShellExecute” method):

    [code]XM.openExternal = function(filepath)
    {
    if (XM.String.hasContent(filepath)) {
      var objShell = new ActiveXObject(“Shell.Application”);
    objShell.ShellExecute(filepath, “”, “”, “open”, 1);
    objShell = null;
    }
    }[/code]

    In theory what normally happens (when you have not made any file association changes yourself) for a path like C:myfoldermyfile.html is the following:
    1. ShellExecute parses the URL and extracts the “.html” portion. [Note: if it finds “http”, “ftp”, etc, at the start then another path through the registry is taken.]
    2. It then looks for a matching registry key in HKEY_CLASSES_ROOT and should find HKEY_CLASSES_ROOT.html
    3. It extracts the (default) value, which will normally be “htmlfile”.
    4. It then looks for a matching registry key in HKEY_CLASSES_ROOT and should find HKEY_CLASSES_ROOThtmlfile
    5. It then looks for the subkey shellopencommand and should find HKEY_CLASSES_ROOThtmlfileshellopencommand
    6. The value for (default) should normally be used.

    XMetaL itself does not set such values (we don't try to take over file extension associations for double click like many other apps do mostly because we integrate with many 3rd party systems so it is best to let them set this up).

    However, when you use Windows Explorer to associate a file extension with an application the following is set, and it is this value that should (as far as I know) get first crack at it (ie: if it exists then it should take precedence):

    HKUSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.htmlApplication

    This makes me think that Microsoft is doing some chicanery here, somehow bypassing (what I think is) the “normal” routine that is not obvious to me yet. Either that, or I don't properly understand the workings of ShellExecute.

    I don't think we can improve our code here. There is no better way to do this as far as I can tell. So, what I will try to look for is the magic registry entry that needs to be set (assuming there is one).

    Reply

    gcrews

    Reply to: Opening XHTML file in Xmetal from map

    This is kind of a hack but it seems to work. If I make a copy of the xmetal60.exe file, say xmetal60.copy.exe and then associate .html files with xmetal60.copy.exe the  .html links will open from a map. Since I suspect XMetaL is doing instance checking the xmetal60.copy.exe executable never fully opens another instance but the file gets passed back to the original xmetal60.exe.

    Now that I know when that external trigger code is I will likely just change how Xmetal handles .html files and not the system. That works better to because IE would always want to reset .html to IE as the default program. Thanks for the help.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support