Support Requests item #965570, was opened at 2004-06-03 10:20 Message generated for change (Comment added) made by maartenc You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=216035&aid=965570&group_id=16035
Category: None Group: None >Status: Closed Priority: 5 Submitted By: Nobody/Anonymous (nobody) >Assigned to: Maarten Coene (maartenc) Summary: Problem saving large document using version 1.4 Initial Comment: When saving a document with about 10000 elements (very small elements: <id>6464</id>) the XMLWriter seems to stop after about 120 KB filesize. It just stops writing. So the result are unclosed or incomplete nodes. This is on Mac OS X 10.3 using Java 1.4.2 and dom4j 1.4. Can this be fixed using the 1.5 beta? Is it recommended to use 1.5 in production? Regards, Alex [EMAIL PROTECTED] ---------------------------------------------------------------------- >Comment By: Maarten Coene (maartenc) Date: 2004-06-04 10:39 Message: Logged In: YES user_id=178745 Problem solved: as stated in the XMLWriter javadoc: if a java.io.Writer is used to write a Document, the Writer should be flushed after the XMLWriter.write(Document) method returns... Alex wrote: >Hi Maarten, > >thanks for your quick response. Works now! >Seems that the "FileWriter" was the problem here. >Do you have any idea why? > >Here is my code: > >public static void save(String name, Integer[] pks, File f) throws IOException { > Document document = >DocumentHelper.createDocument(); > Element root = document.addElement("set"); > root.addAttribute("name",name); > > if(pks != null && pks.length > 0) { > for(int i = 0; i < pks.length; i++) { > >root.addElement("id").setText(pks[i].toString()); > } > //FileWriter fw = new FileWriter(f); // Does not work > FileOutputStream fw = new FileOutputStream(f); // Works > XMLWriter writer = new XMLWriter(fw, >OutputFormat.createPrettyPrint()); > writer.write(document); > } > } > >Regards, > >Alex ---------------------------------------------------------------------- Comment By: Maarten Coene (maartenc) Date: 2004-06-03 13:29 Message: Logged In: YES user_id=178745 I cannot reproduce this problem with dom4j 1.4 Executing this code works without problem for me: Document doc = DocumentFactory.getInstance().createDocument(); Element root = doc.addElement("root"); for (int i = 0; i < 100000; i++) { Element id = root.addElement("id"); id.setText("bla" + i); } XMLWriter writer = new XMLWriter( new FileOutputStream("c:\temp\bug.xml")); writer.write(doc); Could you try the code above to see if this works on your system? Maarten ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=216035&aid=965570&group_id=16035 ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. >From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ dom4j-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev