Introduction
This archival retrieval solution is appropriate for applications that do not use any database, but an XML data source. When it comes to speed, I can say that XSLT is the best in terms of data crunching. In this article, I describe how this retrieval solution works using ASP and calls an XSLT program that accesses an XML file. This is a simple prototype that gives you an idea of how XSLT gets interfaced with an ASP application.
Using the Code
Just add or copy the source code file into the wwwroot folder (IIS root folder). Then you can access the file by calling it from the browser.
- Add search.asp to the created folder for the archiver. This contains the ASP code that allows the entry of queries.
xslFile = "general.xsl"
xmlFile = "test.xml"
Set xslDoc = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
xslDoc.async = false
xslDoc.load(Server.MapPath(xslFile))
Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlDoc.async = false
xmlDoc.load(Server.MapPath(xmlFile))
Set myTemplate = Server.CreateObject("MSXML2.XSLTemplate")
myTemplate.stylesheet = xslDoc
Set myProc = myTemplate.createProcessor
myProc.input = xmlDoc
myProc.transform
Response.Write(myProc.output)
- Add general.xsl as the query statement on the XML file.
<xsl:for-each select="//HAWB[@HawbNo=$p_hawb]">
<tr>
<td><xsl:value-of select="IDNO"/></td>
<td><xsl:value-of select="SHIPDATE"/></td>
<td><xsl:value-of select="DECLNO"/></td>
<td><xsl:value-of select="CONSCOM"/></td>
<td><xsl:value-of select="SHIPCOM"/></td>
</tr>
</xsl:for-each>
- Add test.xml as the test data formatted in XML.
="1.0"="ISO-8859-1"
<DATALOG>
<HAWB HawbNo="815710000000">
<IDNO>AA000003285001</IDNO>
<DECLNO>182106240</DECLNO>
<SHIPDATE>1/1/1998</SHIPDATE>
<CONSCOM>CONSIGNEE COMPANY 1 Inc </CONSCOM>
<SHIPCOM>SHIPPER COMPANY 1 Inc</SHIPCOM>
</HAWB>
<HAWB HawbNo="815710000001">
<IDNO>AA000003285002</IDNO>
<DECLNO>182106241</DECLNO>
<SHIPDATE>1/1/1998</SHIPDATE>
<CONSCOM>CONSIGNEE COMPANY 2 Inc </CONSCOM>
<SHIPCOM>SHIPPER COMPANY 2 Inc</SHIPCOM>
</HAWB>
<HAWB HawbNo="815710000002">
<IDNO>AA000003285003</IDNO>
<DECLNO>182106242</DECLNO>
<SHIPDATE>1/1/1998</SHIPDATE>
<CONSCOM>CONSIGNEE COMPANY 3 Inc </CONSCOM>
<SHIPCOM>SHIPPER COMPANY 3 Inc</SHIPCOM>
</HAWB>
</DATALOG>