Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2006, 02:51 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to make high effective use of MSXML obj

I've tried the code below to work on my page.They just works good but not effective enough.Everytime the activex object is created,the js retrieve xsl file and files inclued in it from server and that terribly do harm to the efficiency of the system.Because my server is embeded in some kind of equipment.So ,is there is a way that I can create the xslt object using files obtained from the IE cache when they were first loaded in the cache ,just like othe cgi requests do?
.................................................. ..............
function createXSLDOM() {
var arrSignatures = ["Msxml2.FreeThreadedDOMDocument.6.0","Msxml2.F reeT hreadedDOMDocument.5.0", "Msxml2.FreeThreadedDOMDocument.4.0",
"Msxml2.FreeThreadedDOMDocument.3.0", "Msxml2.FreeThreadedDOMDocument.2.0",
"Msxml2.FreeThreadedDOMDocument"];
for (var i=0; i < arrSignatures.length; i++) {
try {
var oXslDom = new ActiveXObject(arrSignatures[i]);
return oXslDom;
} catch (oError) {
//ignore
}
}
throw new Error("MSXML is not installed on your system.");
}
function loadAreaPage(areaObject,xmlName,xslName,callback){
var xslDoc = createXSLDOM();
var xmlDoc = createXMLDOM();
try{
xmlDoc.async=true
xslDoc.validateOnParse=false
xmlDoc.load(xmlName)
xmlDoc.onreadystatechange=function(){
if(xmlDoc.readyState==4){
xslDoc.load(xslName)
}
}
xslDoc.onreadystatechange=function(){
if(xslDoc.readyState==4){
if(!xslDoc || !xmlDoc || xslDoc.text.length==0){
xmlDoc=null
xslDoc=null
return
}
areaObject.innerHTML=xmlDoc.transformNode(xslDoc)
xmlDoc=null
xslDoc=null
try{
callback()
}catch(exc){}
}
}
}catch(exc){}}
.................................................. ..............

Tks,everybody and wait......
 
Old March 24th, 2006, 03:24 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

In my experience these documents are cached and re-used. Can you tell us a little more about the environment this code is running on?


--

Joe (Microsoft MVP - XML)
 
Old March 24th, 2006, 04:08 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok,thanks a lot.I'd describe it in more detail.
Eviroment:
os:windowsXp IE6(sp2);
web server(named goAhead):embeded in our equipment whose platform is vxWorks;
tech we are using is xslt & javascript & xml.
Response to cgi request is an xml flow and IE retreive the specified xsl file to show html information.We've got some area(always "<td/>") in the page to show detail information of each item in a table.We use the upper descriped funcion named "loadAreaPage" to do this.

The point is :usual cgi request just get xsl file and files inclued in it once unless user refresh page by force,for xsl files are cached.in the "loadAreaPage" case,everytime IE will retreive xsl files from the server.we have to load the "areapage" with "async=true" because the resource our equipment can use is very limited.As the IE keep reloading files ,the whole efficiency of system is terrible and something must go wrong and something must be done.

Thanks again for the reply!!


The one who success never gives up &amp; the one who gives up never success.
 
Old March 24th, 2006, 04:34 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if the XSL doesn't change, just the XML, then don't recreate the XSL DOM each time. Store it after first use and then re-use it:
Code:
var oXSLT = null;
function createXSLDOM()
{
  if (!oXSLT)
  {
    //create and load object
  }
  return oXSLT;
}
Alternatively store the stylesheet in an XML data island, these are cached locally.

If the XML changes each time then presumably you need to call the server each time but again you can re-use the actual COM object, you don't have to instantiate it each time.

--

Joe (Microsoft MVP - XML)
 
Old March 24th, 2006, 06:22 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

  The problem about the "Msxml2.FreeThreadedDOMDocument" object retieving xsl files from server is just trubling me.I've tryed the method you suggest;unfortunately it doesnt work well.I think maybe the point is why IE is always trying to obtain files from server except from the cache.If I create a variable storing the specified xsl doc for reuse,maybe it works in one page.But when I turn to other pages and then turn back,will the variable still exist or not? If not,the the IE retreive again and that does not work like other simple request dealing of IE.Otherwise,if IE obtain xsl files from cashe(Every specified named xsl file never change unless you update the server),even the variable disappeared ,the speed is high enough to accept.
       I'm confused about the inside mechanism of MSXML class.Is there anyway to cache the xsl file by xslObj.load() for the next-time use but not the variable?

The one who success never gives up &amp; the one who gives up never success.
 
Old March 24th, 2006, 07:10 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if IE is set to retrieve each time you can't do much, this is the user's choice.
If you split the pages into a frameset of two frames you can store the XML/XSLT in a constant frame and just change the other frame.
In my experience IE normally caches requests, most problems are the opposite of yours, how to make sure IE gets a fresh copy each time.

Perhaps using an XML data island to store the stylesheet will help?
Code:
<xml id="xsltData" src="<url here>"></xml>
Then when you need to use it:
Code:
XSLDom.load(xsltData.XMLDocument);
--

Joe (Microsoft MVP - XML)
 
Old March 26th, 2006, 10:19 PM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It seems not possible to include '<xml>'tag in a XSL stylesheet? Do you mean insert
the XML data island in XSL file?

The one who success never gives up &amp; the one who gives up never success.
 
Old March 26th, 2006, 10:42 PM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In my case ,I set IE to check the page update automatically.In fact I can see the IE-Server request-response in a console window provided by the server.For a common
request like "http://127.0.0.1/sse/service/snc_browse?session=57813&subType=5630E",
the server response an xml file flow inside which an xsl src is specified.Then IE obtain the xsl file in a usual way and it is cached and reuseful.But when I create
an xsl DOM object with js(usually by xslObj.load("xslFileName")),IE get the xsl file just in another way by wich xsl files cannot be cached at all.

The one who success never gives up &amp; the one who gives up never success.
 
Old March 26th, 2006, 11:52 PM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It does work with XML data island,but a new problem raises up.Some xsl files (like common.xsl)included in the XML data island are retreived everytime.I'm trying to use data island again to solve it.Thanks a lot.

The one who success never gives up &amp; the one who gives up never success.
 
Old March 27th, 2006, 02:33 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Finally I've tried the two methods:one with js obj creating once and the other with
xml data island;and I choose the latter one.The efficiency improves about 33%--40%.One thing needs to be attentioned is that both the xml data island and the newed js obj storing the xsl file keep retreiving xsl files included times and times again no matter how you set your IE config.I think maybe there is a way to solve this.

The one who success never gives up &amp; the one who gives up never success.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do effective testing on WCF SendilKumar Windows Communication Foundation 1 July 31st, 2009 04:02 AM
help me to make high light menu at VS 6. C++ asdfci Visual C++ 0 July 24th, 2007 12:24 PM
How to work through huge amounts of data effective Planet_Jeroen Excel VBA 2 January 16th, 2007 08:12 AM
Very high XSL Problem markus2000 XSLT 2 June 8th, 2006 04:51 PM
Page Faults High niallhannon SQL Server 2000 1 February 25th, 2004 05:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.