PLEASE DO NOT REPLY TO THIS MESSAGE. TO FURTHER COMMENT ON THE STATUS OF THIS BUG PLEASE FOLLOW THE LINK BELOW AND USE THE ON-LINE APPLICATION. REPLYING TO THIS MESSAGE DOES NOT UPDATE THE DATABASE, AND SO YOUR COMMENT WILL BE LOST SOMEWHERE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2308 *** shadow/2308 Tue Aug 7 03:31:11 2001 --- shadow/2308.tmp.13697 Sun Aug 12 13:54:51 2001 *************** *** 2,9 **** | Out of memory caused by simple custom Node Iterator. | +----------------------------------------------------------------------------+ | Bug #: 2308 Product: XalanJ2 | ! | Status: NEW Version: CurrentCVS | ! | Resolution: Platform: All | | Severity: Normal OS/Version: Windows NT/2K | | Priority: Other Component: org.apache.xalan.extens | +----------------------------------------------------------------------------+ --- 2,9 ---- | Out of memory caused by simple custom Node Iterator. | +----------------------------------------------------------------------------+ | Bug #: 2308 Product: XalanJ2 | ! | Status: RESOLVED Version: CurrentCVS | ! | Resolution: FIXED Platform: All | | Severity: Normal OS/Version: Windows NT/2K | | Priority: Other Component: org.apache.xalan.extens | +----------------------------------------------------------------------------+ *************** *** 114,116 **** --- 114,191 ---- ------- Additional Comments From [EMAIL PROTECTED] 2001-08-07 03:31 ------- Just classifying bugs as Keywords:APIBug == bugs that pertain to specific API calls or advanced usage of Xalan. + + ------- Additional Comments From [EMAIL PROTECTED] 2001-08-12 13:54 ------- + This bug brings up several issues similar to bug 2307 + (http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2308). First, by increasing + the maximum java heap size, the OutOfMemory exception is avoided but replaced + with an ArrayIndexOutOfBounds. This was due to some bugs in the DTM support + that allowed the DTM Id to go negative instead of treating it as unsigned. + Also, DTM Ids larger than the maximum support Id could be returned. Committed + DTMManager, revision 1.6 and DTMManagerDefault, revision 1.20 to solve these + problems. An DTMException with a "No More DTM IDs are available" message is now + returned. + + Since I'm working with the latest CVS, part of this problem was due to Joe's + change that reduced the number of DTM Ids by two bits or a factor of four. This + change was not reflected in the m_dtms size array but now it will automatically + be so reflected. + + Next, is the problem of the actual implementation of the extension. As + discussed in bug 2307, the stylesheet should actually be: + + <?xml version="1.0"?> + <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:java="http://xml.apache.org/xslt/java" + version="1.0"> + <xsl:template match="/"> + <xsl:for-each select="java:Bug2308.new()" /> + </xsl:template> + </xsl:stylesheet> + + The constructor returns a NodeIterator and this is then iterated to generate the + node-set. No additional calls to getNextNode() are appropriate. + + Finally, each call was generating a brand new DTM. This is because the nodes + being returned by getNextNode() (which is automatically being called by XalanJ), + are orphaned nodes not owned by any Document. In order to correct this, you'll + need to change the constructor to create a DocumentFragment (since a document + can have only one child element). The new constructor looks like this: + + DocumentBuilderFactory objFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder objBuilder = objFactory.newDocumentBuilder(); + mobjDocument = objBuilder.newDocument(); + mobjDocFrag = mobjDocument.createDocumentFragment(); + + I also had to add a field into the class like this: + + private org.w3c.dom.DocumentFragment mobjDocFrag; + + Finally, the getNextNode() is changed to add the newly created node as a child + of the DocumentFragment. In this way, only one DTM with 50,000 children is + created instead of 50,000 DTMs (which exceeds XalanJ's limit) each with only one + child. + + public Node nextNode() throws DOMException { + mlngCount++; + if (mlngCount<50000) { + org.w3c.dom.Element objElement = mobjDocument.createElement("Hello"); + objElement.setAttribute("value", String.valueOf(mlngCount)); + mobjDocFrag.appendChild(objElement); + return objElement; + } + return null; + } + + With this implementation, XalanJ iterates through all of the nodes in your + NodeIterator before creating a node-set so that it can continue. I'm not sure + what you're actually trying to do in real life, but you may want to look at + creating your own DTM implementation so that you can do some incremental + returning. + + This is a lot more work, obviously, and you might contact John Gentilin on the + Xalan-dev list who is in the final stages of doing this for the SQL Extension. + Not recommended for the casual user. + + HTH, + Gary \ No newline at end of file
