VERY COOL!
I've got some code that you might be interested in... It's pretty basic,
but it implements a browser-based transformation DOM cache which assigns
an ID to a particular DOM that has been transformed, storing the result
in an array cache. It then checks the array cache before running a
transformation to see if its already been run, and if yes, returns the
DOM from the cache instead.
I wrote this one morning who knows how long ago, and never came back to
it (the name of the file alone to make that an easy point to notice ;),
so without a doubt it can be improved upon, but if its something that
you find useful, you can access it here >
http://www.xsltblog.com/xslclient-test.js
The pertinent pieces of code are,
function loadXMLFeed(feedID){
var inMemory = false;
var xmlFeedLength = xmlFeeds.length;
var i;
for (i = 0; i< xmlFeedLength; i++){
if (xmlFeeds[i][0] == feedID){
inMemory = true;
return xmlFeeds[i][1];
}
}
if (!inMemory){
for (i = 0; i< xmlURLList.length; i++){
if (xmlURLList[i][0] == feedID){
var tempDoc = loadAtomFeed(xmlURLList[i][1]);
xmlFeeds[xmlFeedLength] = new Array(feedID, tempDoc);
return tempDoc;
}
}
}
return false;
};
And,
function checkTransformCache(target, dom, style, xmlfeed){
var inCache = false;
var i;
if (transformCache.length){
for (i = 0; i< transformCache.length; i++){
if (transformCache[i][0] == xmlfeed){
target.innerHTML = transformCache[i][1];
inCache = true;
}
}
}
if (!inCache){
setDOMSource(dom);
setStylesheet(style);
setFeedID(xmlfeed);
Transform();
}
};
Playing with your code now... Thanks! :D
Robert Koberg wrote:
M. David Peterson wrote:
Hey Robert,
Robert Koberg wrote:
Hi,
I have added some XSL transformation conveniences to the dojo
toolkit (http://dojotoolkit.org - you would need to use SVN and get
the trunk)
WOW! I hadn't realized how big Dojo had become. I've got the
repository checked out. Where can I find your extensions?
Dojo is pretty cool :) Docs kinda suck. The dojo.xml.XslTransform
class is in: dojo/src/xml. Be sure to check out
dojo/tests/xml/test_XslTransform.html for some different uses.
Basically, the public API (I am open to change or extend it to make it
more useful) looks like:
dojo.xml.XslTransform = function(/*String*/ xsltUri) {
/*
Common params:
xmlDoc - the primary XML source
params - a 2 dim array, e.g. [[name, value]] which is cleared after
each transform
parentDoc - the window.document that is the parent of the result
*/
this.getResultString = function(/*XMLDOcument*/ xmlDoc, /*2
Dimensional Array*/params, /*HTMLDocument*/parentDoc)
/*
contentPane - dojo specific layout region to put the result into
(instatiates child widgets)
*/
this.transformToContentPane = function(/*XMLDOcument*/ xmlDoc, /*2
Dimensional Array*/params, /*ContentPane*/contentPane,
/*HTMLDocument*/parentDoc);
/*
region - some HTML element to put the result into
*/
this.transformToRegion = function(/*XMLDOcument*/ xmlDoc, /*2
Dimensional Array*/params, /*HTMLElement*/region,
/*HTMLDocument*/parentDoc);
this.transformToDocument = function(/*XMLDOcument*/ xmlDoc, /*2
Dimensional Array*/params);
this.transformToWindow = function(/*XMLDOcument*/ xmlDoc, /*2
Dimensional Array*/params, /*HTMLDocument*/windowDoc,
/*HTMLDocument*/parentDoc);
}
best,
-Rob
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--
/M:D
M. David Peterson
http://mdavid.name | http://www.oreillynet.com/pub/au/2354
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--