|
Subject: RE: [xsl] XML Dom Caching From: Kanthi <kan_manikoth@xxxxxxxxx> Date: Tue, 12 Aug 2003 05:14:13 -0700 (PDT) |
HI Jennifer -
I appreciate the reply. So it looks I will have to
clone the node if I want to use the cached DOM without
directly making changes to it during the processing of
my code.
i.e Using, set objDOM = Application("CachedXMLData")
will cause the "CachedXMLData" to be altered if objDOM
is altered. Am I correct in thinking this?
Thanks
Kan
--- Jennifer Phillips <jennifer@xxxxxxxxxx> wrote:
> >Does anyone know whats the best way to cache an xml
> >dom in global.asa [ASP/VBScript] ?
>
> I dont know about the best way, but the way I do it
> is below...
>
> >I have a number of XML documents that are used
> extensivly
> >in my code and I did not want to load them each
> time but
> >instead cache it so that I can just call it once
> and
> >keep resuing it.
>
> Wise move, just be a little careful about the memory
> usage of storing so
> many DOM's in memory, you could end up slowing the
> whole thing down rather
> than speeding it up.
>
> >Once I cache it what is the best way to call is
> besides
> >Application(strCachedDom).cloneNode(true) ?
>
> I just set an object reference to the DOM in the
> Application object, however
> this does have one drawback, if you change the DOM
> referenced in the
> variable, you also change the cached version in the
> Application object
> (Since they are the same thing), if you need to
> change the data in the DOM
> you will have to clone it (Unless you want the
> cached version updated also).
>
> Anyway here's the code.....
>
> I personally dont start the cache in the Globet.asa,
> because my data is
> updated quite often so each time its hit, it needs
> to check the cache is
> still fresh, so this goes into an ASP page, shouldnt
> be too hard to modify
> to go into the Global.asa.
>
> ' This IF checks whether we have any cached data or
> we have asked to updated
> it.
> if isEmpty(Application("CachedXMLData")) or _
> Request("refresh") = "true" then
>
> ' load the XML document
> ' IMPORTANT!!!!! To be stored in the
> application object it
> ' MUST be a FreeThreaedDOMDocument NOT a
> DOMDocument
> set xml =
>
Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
>
> ' Load in the XML
> call loadXMLFile(xml, "C:\MyData.XML")
>
> ' Save it to the Application object
> call updateAppVariable("CachedXMLData", xml)
> end if
> end if
>
> Sub loadXMLFile(xmldoc, filename)
> if not xmldoc.load(filename) then
> Response.Write "Error loading the file '" _
> & filename & "'.<br>"
> Response.Write "Description: " & _
> xmldoc.parseError.reason & "<br>"
> Response.Write "Line: " & _
> xmldoc.parseError.line & "<br>"
> Response.Write "Line position: " _
> & xmldoc.parseError.linepos & "<br>"
> Response.End
> end if
> End Sub
>
> Sub updateAppVariable(varName, value)
> Application.Lock
>
> if isObject(value) then
> set Application(varname) = value
> else
> Application(varname) = value
> end if
>
> Application.UnLock
> End Sub
>
>
> Then to retrieve the DOM data....
>
> set objDOM = Application("CachedXMLData")
>
>
> If you are doing a lot of XSLT with the cached XML
> data, its also good to
> store the XSLT template in the application object
> too since then its
> pre-compiled, on the pages I've done this on,
> combined with the XML caching,
> I got a 5 fold performance increase.
>
> If you have any further questions let me know.
>
> Jenni Phillips
>
>
>
> XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] XML Dom Caching, Jennifer Phillips | Thread | RE: [xsl] XML Dom Caching, Jennifer Phillips |
| Re: [xsl] OFF Subject..., michel geadah | Date | Re: [xsl] OFF Subject..., Simon Kelly |
| Month |