[From nobody Fri Aug 6 17:09:19 2004 Return-Path: <venkialagar@yahoo.com> Received: from web13703.mail.yahoo.com (web13703.mail.yahoo.com [216.136.175.136]) by jhunter.xquery.com (8.12.8/8.12.9) with SMTP id i5FNeJNr001183 for <jhunter@xquery.com>; Tue, 15 Jun 2004 16:40:19 -0700 Message-ID: <20040616012512.26638.qmail@web13703.mail.yahoo.com> Received: from [24.176.8.52] by web13703.mail.yahoo.com via HTTP; Tue, 15 Jun 2004 18:25:12 PDT Date: Tue, 15 Jun 2004 18:25:12 -0700 (PDT) From: venki alagar <venkialagar@yahoo.com> Subject: Re: JDOM Transformer Problem To: Jason Hunter <jhunter@xquery.com> In-Reply-To: <40CA340F.9010004@xquery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on jhunter.xquery.com X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=ham version=2.63 X-Spam-Level: Hi Jh, Thanks for your prompt reply and your help. But I want to give you this detail, 1.I changed private access modifier of flushCharacter() method to protected in SAXHandler class. 2. JDOMResult.java - I modified method getResult() by calling the flushCharacter() method in inner class FragmentHandler. Now I am getting correct List with values. Thanks Venki --- Jason Hunter <jhunter@xquery.com> wrote: > Hi Venki, > > When the mailing list comes back (I wish I had > control over when that > would be) you can post this there. That's the best > forum. I don't have > time to review it right now. > > -jh- > > venki alagar wrote: > > > Hi, > > > > I want to read a complex xml file using JDOM and > get > > the required values from xml and create a csv > file. > > For that when I tried below 2 options, > > 1. Using the Element names directly in the > code(Hard > > coded) with complex logic to get the correct Data > from > > the file- It works fine. > > > > 2.Using xsl sheet without Hard coding the Element > > names in the Program.To achieve this, > > > > 2.1 I used the following code as given in your > > example. > > But getResult() method always returns Empty List. > > Bur out.toString() returns object value. > > Why List is empty? > > public static List transform(Document doc, String > > stylesheet) > > hrows JDOMException { > > try { > > Transformer transformer = > > TransformerFactory.newInstance() > > .newTransformer(new > > StreamSource(stylesheet)); > > JDOMSource in = new JDOMSource(doc); > > JDOMResult out = new JDOMResult(); > > transformer.transform(in, out); > > return out.getResult(); > > } > > catch (TransformerException e) { > > throw new JDOMException("XSLT > Trandformation > > failed", e); > > } > > } > > > > 2.2 When I use the below code ,the Output stream > > returs all values correctly.I can manupulate the > > Result using String Tokenizer. > > > > TransformerFactory tFactory = > > TransformerFactory.newInstance(); > > //Make the input sources for the XML and > > //XSLT documents > > org.jdom.output.DOMOutputter outputter = new > > org.jdom.output.DOMOutputter(); > > org.w3c.dom.Document domDocument = > > outputter.output(myDocument); > > javax.xml.transform.Source xmlSource = new > > javax.xml.transform.dom.DOMSource(domDocument); > > StreamSource xsltSource =new > > StreamSource(new FileInputStream(stylesheet)); > > > > StreamResult xmlResult = new > StreamResult(System.out); > > //Get a XSLT transformer > > Transformer transformer = > > tFactory.newTransformer(xsltSource); > > transformer.transform(xmlSource, xmlResult); > > > > > > My Questions are, > > 1. Why JDOM getResult() method always return empty > > List? > > 2.Whether 2nd method is correct way to read the > xml > > file. > > 3.Which is better performance wise? > > 4.Are there any other ways to read complex xml(I > don't > > need to read all the elements.I am going to read > only > > 20% of the elements in the file) to create csv > file > > with required data and same thing for converting > csv > > file into XML File. > > > > My advance thanks for your help. > > Venki > > > > > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Friends. Fun. Try the all-new Yahoo! Messenger. > > http://messenger.yahoo.com/ > > __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail ]