Click here to Skip to main content
Licence CPOL
First Posted 9 Oct 2006
Views 13,976
Downloads 90
Bookmarked 12 times

Archival Retrieval Solution for ASP Using XML Data

By | 9 Oct 2006 | Article
Retrieving data from XML using column indexing.

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.

  1. Add search.asp to the created folder for the archiver. This contains the ASP code that allows the entry of queries.
  2. ' Source file '
    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))
    
    'This is the critical widget, a compliled XSL template'
    Set myTemplate = Server.CreateObject("MSXML2.XSLTemplate")
    myTemplate.stylesheet = xslDoc
    
    Set myProc = myTemplate.createProcessor
    myProc.input = xmlDoc
    
    myProc.transform
    Response.Write(myProc.output)
  3. Add general.xsl as the query statement on the XML file.
  4. <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> 
  5. Add test.xml as the test data formatted in XML.
  6. <?xml version="1.0" encoding="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>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

valdo_gmail

Web Developer

Hong Kong Hong Kong

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralSource code missing Pinmembercornejoserrano12:28 20 Nov '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 10 Oct 2006
Article Copyright 2006 by valdo_gmail
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid