Such a tool should have a window to provide a preview of the file it is working on. In addition, an address bar and a couple of buttons to navigate to the specified URL or local file and to run an Open file dialog are certainly useful.
Furthermore, we need something to keep track of all the files that seem to contribute to the perfect working of the Scriptlet. A listbox would be fine. We'll fill in it as soon as we've progressed through the Dynamic HTML object model and know about nested files. The screenshot below shows how the user interface of this packaging tool might look.
A user of this DHTML X-Ray utility, would click on the Browse button or type in the name of the HTML file to be analyzed. By clicking the Go or the Browse buttons, he or she will cause the specified Web document to be loaded and displayed through a WebBrowser control.
The picture above shows how it will look afterwards. At this point, all that remains to be done is to get a reference to the document object model and analyze it via collections and other means. By clicking on the Walk button, we do just this.
Before we start analyzing the details of this utility, let's state that it won't be the definitive routine for such a task. First, we'll be covering a significant—but incomplete—subset of all the possible HTML tags. Second, the Dynamic HTML object model is of no help when we're in the presence of dynamic changes to the file structure.
The metaphor we discussed earlier, regarding the similarity between the Win32 executables and the HTML pages, is yet again particularly appropriate. If we go through the executable Win32 file format searching for the dependency list, we will only be able to obtain the names of the libraries referenced statically.
All those to which the module links dynamically are excluded from our search. Simply, those names aren't coded in the readable and conventional
section, so there's no way to find out about them. What you could do, alternatively, is scan the bytes of the file searching for any possible file name. EXPORT
For HTML documents, things go much the same. The traditional way to find out about the HTML dependency-list is to go through the Dynamic HTML collections and attributes. However, if you're considering a Scriptlet that changes its user interface dynamically, adding or removing images, sounds, or even controls, then you won't be able to trace all the files needed. Or rather, you can't do that simply by going through the element collections. Instead, supposing you could really do this work, you ought to examine character by character all the body and the single instructions of the HTML file.
In conclusion, our DHTML X-Ray tool helps to extract a subset of the file names that you need to package before deploying your Scriptlet component. However, once the tool has finished working there might be other files to take into account.