Return-Path: Mailing-List: contact xalan-j-users-help@xml.apache.org; run by ezmlm Delivered-To: mailing list xalan-j-users@xml.apache.org Received: (qmail 59384 invoked from network); 31 Jul 2001 15:13:45 -0000 Received: from lotus2.lotus.com (129.42.241.42) by h31.sny.collab.net with SMTP; 31 Jul 2001 15:13:45 -0000 Received: from internet2.lotus.com (internet2 [172.16.131.236]) by lotus2.lotus.com (8.11.4/8.11.4) with ESMTP id f6VFEE509343; Tue, 31 Jul 2001 11:14:14 -0400 (EDT) Received: from cammail04.lotus.com (cammail04.lotus.com [9.95.4.116]) by internet2.lotus.com (8.11.4/8.11.2) with ESMTP id f6VFDIw11922; Tue, 31 Jul 2001 11:13:18 -0400 (EDT) Subject: Re: Performance problems when passing node-set as global XSLT parameter To: "Evan Lenz" Cc: xalan-j-users@xml.apache.org X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 Message-ID: From: Scott_Boag@lotus.com Date: Tue, 31 Jul 2001 10:55:15 -0400 X-MIMETrack: Serialize by Router on CAMMAIL04/CAM/M/Lotus(Release 5.0.7 |March 21, 2001) at 07/31/2001 11:10:00 AM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Hi Evan. In 2.1.0 we used the DOM API raw. That means that for certain constructs, we would have to do document order comparisons by walking up the ancestor chain. There are some other issues also with using a foreign DOM. When you use the Document function, we can create our own optimized DOM (Stree). I think this is what you're seeing. I'm curious what happens with your test with XalanJ 2.2.D8 (or the latest CVS build). (In 2.2.x we no longer use the DOM API internally, but instead use the DTM [Document Table Model]. When you pass in a DOM, we have an adapter to the DTM interface.) -scott "Evan Lenz" d.com> cc: (bcc: Scott Boag/CAM/Lotus) Subject: Performance problems when passing node-set as global XSLT 07/30/01 parameter 08:23 PM I have a situation where I want to repeatedly pass a large node-set, which contains a set of root nodes from various documents, as a global XSLT parameter into multiple stylesheets. The node-set stays the same and the stylesheets change. For some reason, I'm having serious performance problems when passing XNodeSet in as a parameter. In fact, in most cases it's faster to re-parse the entire set of documents using the document() function repeatedly at run-time! I'm using xalan-j_2_1_0. Here are the relevant code snippets: Example stylesheet: Java: First, I construct an instance of XNodeSet which contains a set of root nodes: private DocumentBuilderFactory bFactory; private Hashtable database = new Hashtable(); private XNodeSet nodeSet; private File databaseDir; . . . for (int i = 0; i < fileNames.length; i++) { File file = new File(databaseDir, fileNames[i]); if (!file.isDirectory()) { DocumentBuilder builder = bFactory.newDocumentBuilder(); Document doc = builder.parse(file); database.put(fileNames[i], doc); } } NodeSet tempNodeSet = new NodeSet(); Enumeration enum = database.elements(); while (enum.hasMoreElements()) { tempNodeSet.addElement((Node)enum.nextElement()); } nodeSet = new XNodeSet(tempNodeSet); . . . Then, I repeatedly invoke different transformations using the same node-set parameter. Each invocation takes approximately 8 times as long as if I were to use the document() function, parsing the documents over and over again! transformer.setParameter("foo", nodeSet); transformer.transform(source, new StreamResult(out)); My expectation is that performance should be better constructing XNodeSet once as opposed to invoking document() repeatedly, but exactly the reverse is true! If anyone can tell me what's going on or point me to a different object that I should be using (as opposed to XNodeSet), I'd greatly appreciate it. I suspect that I should be building XNodeSet in a different way (as opposed to accumulating DOM instances); I'd appreciate any direction in how to do this. Thanks, Evan Lenz XYZFind Corp.