Click here to Skip to main content
14,110,477 members
Click here to Skip to main content
Add your own
alternative version

Stats

24K views
147 downloads
12 bookmarked
Posted 9 Oct 2006
Licenced CPOL

Archival Retrieval Solution for ASP Using XML Data

, 9 Oct 2006
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

valdo_gmail
Web Developer
Hong Kong Hong Kong
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralSource code missing Pin
cornejoserrano20-Nov-06 12:28
membercornejoserrano20-Nov-06 12:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Cookies | Terms of Use | Mobile
Web02 | 2.8.190518.1 | Last Updated 10 Oct 2006
Article Copyright 2006 by valdo_gmail
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid