|
||
| Inside Technique : Professional ASP XML : The Test Page Now let's see this all at work by looking at the test page, which is included in the source download as default.asp. We will use the JavaScript alert()function to display the XML because if we show it in the browser the tags will not be visible. When it loads, the test page will invoke the init()function. It will create two instances of the XML DOM, one for the XML source document, and the second for the dynamic XSL file. The last thing it does is apply the XSL to the source XML, and saves the resulting string in the "processed" variable. This is our translated XML. The full code is shown here:
I have provided three buttons on the test page that show the three entities that make up this example:
How it WorksThe following screen shot shows the un-translated source document:
This screen shot shows our dynamically generated XSL:
This final screen shot shows the result of the translation:
SummaryIn this chapter, we have seen a way to use ASP to generate an XSL file dynamically. We did this by using an ASP page to create an instance of the XML DOM and employing DOM methods to build the result tree. The information needed to build the result tree came from the contents of an XML file. A test web page then used the dynamic XSL to translate from one XML structure to another. So now we have finished our discussion on styling XML for our web browsers. We will use XSL frequently as we progress through this book. In the next chapter we shall move on to storing and retrieving XML data from databases using ActiveX Data Objects (ADO). Page 1:Professional ASP XML © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |