XSLT caching

F

Floris van Haaster

Hi all,

What I have:

I have a website and in the code I generate a xml document.
I also have a couple of xsl files and then I use the following lines to
generate the website from the xml and xsl:

xslTran.Load(serv.MapPath("default.xsl"))
xslTran.Transform(xmldoc, Nothing, Response.Output(), New XmlUrlResolver)
But now what i want to do is cache the default.xsl so the application
doesn't have to read the file @ avery request.

Does anybody know how to do this?

Thanks in advance!

Floris
 
P

Paul Henderson

I have a website and in the code I generate a xml document.
I also have a couple of xsl files and then I use the following lines to
generate the website from the xml and xsl:
...
But now what i want to do is cache the default.xsl so the application
doesn't have to read the file @ avery request.
Does anybody know how to do this?

Probably the easiest way is to cache the generated XslTransform object
in the application object; you can check if it already exists and
create it if not. Then just extract the transform object and apply it
when needed. So:

Dim xslTran As XslTransform

If Application("myXSLT") = Nothing Then
xslTran = New XslTransform()
xslTran.Load(...)
Application("myXSLT") = xslTran
Else
xslTran = CType(Application("myXSLT"), XslTransform)
End If

xslTran.Transform(...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top