This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
need advice on loading XML file
- From: "Mason Burley" <mason dot burley at nwcsr dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 23 Jan 2002 09:49:59 -0800
- Subject: [xsl] need advice on loading XML file
- Reply-to: xsl-list at lists dot mulberrytech dot com
I have created an XML application for users to view information about
project datasets (www.nwcsr.com/meta). The page works great, but the
data island takes quite awhile to load (5mb). The current approach (in
XSL) looks like this:
*************************************************************
function rewriteOtherFrame(xslURL, variable, datTbl) {
xslStyle.async=false;
xslStyle.XMLDocument.load(xslURL);
var curPattern =
xslStyle.XMLDocument.selectSingleNode('//xsl:for-each/@select');
curPattern.text = "codeBook/fileDscr[@ID='" + variable + "']";
myid.innerHTML = xmlData.transformNode(xslStyle.XMLDocument);
}
//</SCRIPT>
</HEAD>
<BODY>
<XML>
<xsl:attribute name="ID">xslStyle</xsl:attribute>
</XML>
<XML>
<xsl:attribute name="ID">xmlData</xsl:attribute>
<xsl:attribute name="SRC">metaman.xml</xsl:attribute>
</XML>
*************************************************************
My question: Can I find a more efficient way to access this data
(easily) using DOM, or should I try a different approach? I am leary of
using SAX2, because it looks like a big code rework would be necessary.
I did see a SAX example using MSXML 4 and scripting that had a quick
load time (below).
My last question: Can I use transformNode or something else in the
example below to filter the XML file?
Thanks in advance, I am a XSL/XML newbie and appreciate the help,
Mason Burley
*************************************************************
<SCRIPT>
//Create the XSLTemplate object (xslt).
var xslt = new ActiveXObject("Msxml2.XSLTemplate.4.0");
//Create and load the stylesheet (transform1.xsl) as a DOMDocument.
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
var xslProc;
xslDoc.async = false;
xslDoc.load("transform1.xsl");
//Connect the XSLTemplate object to stylesheet DOMDocument.
xslt.stylesheet = xslDoc;
//Create XSLT processor using stylesheet for XSL template.
xslProc = xslt.createProcessor();
//Create and load sample XML file (books.xml) as a DOMDocument.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmlDoc.async = false;
xmlDoc.load("books.xml");
//Create SAX writer.
var xmlWriter = new ActiveXObject("Msxml2.MXXMLWriter.4.0");
//Assign XML sample file as input of the transform() method.
xslProc.input = xmlDoc;
//Use a SAX writer as the output of the transform() method.
xslProc.output = xmlWriter;
//Do transformation on the sample XML file.
xslProc.transform();
//Use SAX writer ouptut to generate inner HTML for page.
result.innerHTML = xmlWriter.output;
</SCRIPT>
*************************************************************
Mason Burley
Northwest Crime and Social Research, Inc.
215 Legion Way SW
Olympia, WA 98501
Tele: (360) 528-3339
FAX: (360) 570-7533
Web: www.nwcsr.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list