Using ASP/IIS to dynamically process XML/XSL (was Re: how to change xsl dynamically?)

Subject: Using ASP/IIS to dynamically process XML/XSL (was Re: how to change xsl dynamically?)
From: "Garriss Jr.,James P." <jgarriss@xxxxxxxxx>
Date: Tue, 14 Sep 1999 08:57:17 -0400
At 04:04 PM 9/13/99 , Mark Stemp wrote:

>Please post some examples!

Ok, here is a very simple example. Please note that this requires ASP to be running on an IIS or PWS server. Only HTML is returned, so any client web browser can be used. Place both these files (match.htm and sxml.asp) in a directory on your Web server together with your XML and XSL files. Set permissions for script. Serve match.htm to your browser.

*** match.htm ***

[HTML and BODY tags deleted]

<!-- pass the values by querystring to sxml.asp -->

<FORM method="get" action="sxml.asp">

<!-- xmldoc* are the filenames of the XML documents -->

<SELECT name="xml">
	<OPTION selected value="xmldoc1">XML Doc #1
	<OPTION value="xmldoc2">XML Doc #1
	<OPTION value="xmldoc3">XML Doc #1
</SELECT>

<!-- xsldoc* are the filenames of the XSL stylesheets -->

<SELECT name="xsl">
	<OPTION selected value="xsldoc1">XSL Doc #1
	<OPTION value="xsldoc2">XSL Doc #2
	<OPTION value="xsldoc3">XSL Doc #3
</SELECT>

<INPUT type="submit" value="Match XML with XSL">

</FORM>

[HTML and BODY tags deleted]

*** sxml.asp ***

[HTML and BODY tags deleted]

<!-- debugging starts here, can be deleted -->

The XML file is <% =Request.QueryString("xml") %>.
<BR>
The XSL file is <% =Request.QueryString("xsl") %>.
<P><HR><P>

<!-- debugging ends here -->

<%
' Note that IE5 must be installed on the server for this to work

' Load the XML document, appending .xml to the filename
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.Load(Server.MapPath(Request.QueryString("xml") + ".xml"))
If objXML.parseError.errorcode <> 0 Then
  Response.write("<error/>")
End If

' Load the XSL stylesheet, appending .xsl to the filename
Set domstyle = Server.CreateObject("Microsoft.XMLDOM")
domstyle.async = False
domStyle.Load(Server.MapPath(Request.QueryString("xsl") + ".xsl"))
If domStyle.parseError.errorcode <> 0 Then
  Response.write("<error/>")
End If

' Dynamically process the XSL against the XML
' only HTML is returned, allowing any web client to be used
Response.Write(objXML.transformNode(domStyle))
%>

[HTML and BODY tags deleted]

James Garriss | The MITRE Corporation | jgarriss @ mitre.org


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread