Return-Path: Delivered-To: apmail-xml-commons-dev-archive@www.apache.org Received: (qmail 70222 invoked from network); 24 Mar 2006 20:08:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Mar 2006 20:08:47 -0000 Received: (qmail 80049 invoked by uid 500); 24 Mar 2006 20:08:47 -0000 Delivered-To: apmail-xml-commons-dev-archive@xml.apache.org Received: (qmail 79759 invoked by uid 500); 24 Mar 2006 20:08:45 -0000 Mailing-List: contact commons-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list commons-dev@xml.apache.org Received: (qmail 79677 invoked by uid 99); 24 Mar 2006 20:08:45 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Mar 2006 12:08:44 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Mar 2006 12:08:43 -0800 Received: by ajax.apache.org (Postfix, from userid 65534) id F1009D4A00; Fri, 24 Mar 2006 20:08:21 +0000 (GMT) From: bugzilla@apache.org To: commons-dev@xml.apache.org Subject: DO NOT REPLY [Bug 39098] New: - Problem parse an xml with SAX Message-ID: X-Bugzilla-Reason: AssignedTo Date: Fri, 24 Mar 2006 20:08:21 +0000 (GMT) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND� INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=39098 Summary: Problem parse an xml with SAX Product: XmlCommons Version: 1.x Platform: PC OS/Version: Windows XP Status: NEW Severity: major Priority: P2 Component: SAX AssignedTo: commons-dev@xml.apache.org ReportedBy: qzheng@harland.net CC: qzheng@harland.net I have a little program which use SAX to parse the xml. The problem is that Xerces split one xml element to two calls to characters method. Below is sample code, xml and result. Code: import java.io.File; import java.io.FileInputStream; import org.apache.xerces.parsers.SAXParser; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; public class TestSAX extends DefaultHandler { private String currentElement = null; /** * @param args */ public static void main(String[] args) { try { SAXParser parser = new SAXParser(); parser.setContentHandler(new TestSAX()); parser.parse(new InputSource(new FileInputStream(new File("C:/test.xml")))); } catch(Exception e) { e.printStackTrace(); } } public void characters(char[] ch, int start, int length) throws SAXException { super.characters(ch, start, length); if (this.currentElement.equals("CreatedDate")) System.out.println(new String(ch, start, length)); } public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { this.currentElement = qName; super.startElement(uri, localName, qName, attributes); } } XML: Result: 2006-03-23 18:22:37.000000 2006-03-22 19:55:37.000000 2006-03-22 17:56:55.000000 2006-03-20 13:39:51.000000 2006-03-17 08:48:28.000000 2006-03-17 08:44:35.000000 2006-03-16 19:02:54.000000 2006-03-16 18:57:31.000000 2006-03-16 08:47:22.000000 2006-03-15 17:44:45.000000 2006-03-14 14:31:37.000000 2006-03-14 10:01:27.000000 2006-03-13 18:23:19.000000 2006-03-13 17:37:00.000000 2006-03-08 17:23:18.000000 2006-03-08 17:21:21.000000 2006-03-08 17:14:07.000000 2006-03-08 16:53:47.000000 2006-03-07 14:44:42.000000 2006-03-07 14:11:26.000000 2006-03-07 13:44:31.000000 2006-03-07 12:18:19.000000 2006-03-07 09:55:55.000000 2006-03-06 12:23:46.000000 2006-03-06 11:56:59.000000 2006-03-06 11:50:52.000000 2006-03-06 11:35:34.000000 2006-03-06 11:27:24.000000 2006-03-06 11:18:40.000000 2006-03-06 11:13:08.000000 2006-03-06 11:02:52.000000 2006-03-06 10:56:43.000000 2006-03-06 10:46:24.000000 2006-03-06 10:23:33.000000 2006-03-06 10:12:06.000000 2006-03-06 09:55:30.000000 2006-03-06 09:35:34.000000 2006-03-06 09:19:04.000000 2006-03-02 09:18:52.000000 2006-03-02 09:03:22.000000 2006-03-02 08:38:35.000000 2006-03-01 17:29:36.000000 2006-03-01 17:22:39.000000 2006-03-01 16:38:40.000000 2006-03-01 15:12:42.000000 2006-03-01 15:00:04.000000 2006-0 2-28 16:59:50.000000 2006-02-28 16:28:53.000000 2006-02-28 13:30:03.000000 2006-02-28 13:09:25.000000 2006-02-28 12:57:45.000000 2006-02-28 12:45:21.000000 2006-02-28 12:35:08.000000 2006-02-28 11:08:41.000000 2006-02-28 09:52:12.000000 2006-02-28 09:33:39.000000 2006-02-28 09:17:01.000000 2006-02-28 08:29:15.000000 2006-02-27 16:15:20.000000 2006-02-27 09:59:56.000000 2006-02-24 09:21:40.000000 2006-02-23 16:34:57.000000 2006-02-23 16:21:26.000000 2006-02-23 16:04:31.000000 2006-02-23 14:58:01.000000 2006-02-23 14:40:29.000000 2006-02-23 14:13:22.000000 2006-02-23 13:11:56.000000 2006-02-23 12:56:14.000000 2006-02-23 10:09:07.000000 2006-02-23 09:45:19.000000 2006-02-23 08:59:57.000000 2006-02-23 08:35:27.000000 2006-02-22 18:04:22.000000 2006-0 2-22 17:43:49.000000 2006-02-22 14:20:34.000000 2006-02-22 13:55:48.000000 -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee.