Return-Path: Delivered-To: apmail-xmlgraphics-fop-users-archive@www.apache.org Received: (qmail 60208 invoked from network); 6 Apr 2007 12:26:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Apr 2007 12:26:48 -0000 Received: (qmail 27983 invoked by uid 500); 6 Apr 2007 12:26:53 -0000 Delivered-To: apmail-xmlgraphics-fop-users-archive@xmlgraphics.apache.org Received: (qmail 27972 invoked by uid 500); 6 Apr 2007 12:26:53 -0000 Mailing-List: contact fop-users-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: fop-users@xmlgraphics.apache.org Delivered-To: mailing list fop-users@xmlgraphics.apache.org Received: (qmail 27961 invoked by uid 99); 6 Apr 2007 12:26:52 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Apr 2007 05:26:52 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [203.143.41.67] (HELO cmbmail.corpnet.ifsworld.com) (203.143.41.67) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Apr 2007 05:26:45 -0700 Received: by cmbmail.corpnet.ifsworld.com with Internet Mail Service (5.5.2653.19) id ; Fri, 6 Apr 2007 17:56:18 +0530 Message-ID: <94FCB3570D8D8040BC376A172F70102B05993242@cmbmail.corpnet.ifsworld.com> From: Harshini Madurapperuma To: fop-users@xmlgraphics.apache.org Subject: RE: Convert InputSource into a Character array Date: Fri, 6 Apr 2007 17:56:17 +0530 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Virus-Checked: Checked by ClamAV on apache.org Hi Sascha; This is my class overview; for u to get a rough idea. Initially I have a char array which I have converted into InputSource. Then within the Driver class in render method I want that InputSource to be converted back into a char array. My class ---------------------------------------------------------------------------- -------------------------- private char[] fo; CharArrayWriter fos = new CharArrayWriter(); fo =fos.toCharArray(); -------------------------- public void myMethod_1 (){ InputSource foSource = new InputSource(new CharArrayReader(fo)); Driver driver = new Driver(); driver.render(xmlReader, foSource); ........ ........ } FOP ---------------------------------------------------------------------------- --------------------------- Driver Class public synchronized void render(XMLReader parser, InputSource source) throws FOPException { if (source.getCharacterStream() != null) { BufferedReader reader = new BufferedReader(source.getCharacterStream()); CharArrayWriter writer=new CharArrayWriter(); int i=-1; while ((i=reader.read())!=-1) { writer.write(i); } reader.close(); writer.close(); } ---------------------------------------------------------------------------- ------------ Thanx Harshini. -----Original Message----- From: Sascha Schmidt [mailto:panther@northbit.de] Sent: Friday, April 06, 2007 4:11 PM To: fop-users@xmlgraphics.apache.org Subject: RE: Convert InputSource into a Character array Hi Harshini, I though you were using a large XML String (/Character-Array) with a CharArrayReader to setup your InputSource. Maybe I was wrong? How do you create your input source? It seems that "someone" uses and closes the InputSource (i.e. the stream) before FOP is invoked? Things are still a bit unclear for me. ;-) Could you please tell me, what you are doing before FOP is invoked and what is done afterwards? Cheers, Sascha > -----Original Message----- > From: Harshini Madurapperuma [mailto:harshini.madurapperuma@ifs.lk] > Sent: Thursday, April 05, 2007 12:55 PM > To: fop-users@xmlgraphics.apache.org > Subject: RE: Convert InputSource into a Character array > > Hi all, and Sascha > > Sascha thanx a lot for ur ideas; but I'm not clear what u have meant > by String xml in the MyInputSource constructor. And from where should > I call this constructor? > > Harshini > > -----Original Message----- > From: Sascha Schmidt [mailto:panther@northbit.de] > Sent: Thursday, April 05, 2007 9:55 AM > To: fop-users@xmlgraphics.apache.org > Subject: RE: Convert InputSource into a Character array > > Hi all, > > I assume Harshini needs to get the original XML-String from a > CharArrayReader (after rendering), which he used to equip the InputSource. > IMHO there is no chance to get the XML-String back, because > CharArrayReader.close() sets the internal Char-Buffer, which holds the > XML-String, to null. Thus one would either need to introduce a new > attribute somewhere in Harshinis class/code or extending class > InputSource. I would prefer the second method. This should give you a > start point: > > class MyInputSource extends InputSource{ > > private String xml; > > public MyInputSource(String xml){ > super(new CharArrayReader(xml)); > } > > public String getXML(){ > return this.xml; > } > } > > > Somewhere later... > > ((MyInputSource) source).getXML() > > returns the xml. > > Note that the code above is not tested, just typed in Outlook. ;-) > > Cheers, > Sascha > > PS: Of course it is correct that FOP closes the stream after > processing it. > > > NORTHBIT > RTF to XSL-FO, Reporting > Dipl. Inf. Sascha Schmidt > panther@northbit.de > www.northbit.de > > > > -----Original Message----- > > From: Harshini Madurapperuma [mailto:harshini.madurapperuma@ifs.lk] > > Sent: Thursday, April 05, 2007 5:18 AM > > To: fop-users@xmlgraphics.apache.org > > Subject: RE: Convert InputSource into a Character array > > > > Hi; > > > > I have this character array, I converted that character array into > > to a InputSource and passed it as a parameter to a > > "render(XMLReader parser, InputSource source)" method in the DRIVER class in fop. > > > > Within that "render" class I need to convert that "InputSource (source)" > > back into a character array (after doing some modifications inside > > that method). I tried to convert that as follows: > > > > > if (source.getCharacterStream() != null) { > > > BufferedReader reader = new > > BufferedReader(source.getCharacterStream()); > > > CharArrayWriter writer=new CharArrayWriter(); > > > int i=-1; > > > while ((i=reader.read())!=-1) > > > { > > > writer.write(i); > > > } > > > reader.close(); > > > writer.close(); > > > } > > > > While doing that it raise this Exception: > > > EXCEPTION--------------------------------------------------------- > > > -- > > > -- > > > ------ > > > ---- > > > > > > java.io.IOException: Stream closed at > > > java.io.CharArrayReader.ensureOpen(CharArrayReader.java:65) at > > > java.io.CharArrayReader.read(CharArrayReader.java:95) at > > > java.io.BufferedReader.fill(BufferedReader.java:136) at > > > java.io.BufferedReader.read(BufferedReader.java:157) at > > > org.apache.fop.apps.Driver.render(Driver.java:557) > > > ------------------------------------------------------------------ > > > -- > > > -- > > > > I need to know the reason or is there any other method to convert > > this and access the content of this inputSource? > > > > Thanx > > Harshini > > > > > > > > -----Original Message----- > > From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] > > Sent: Thursday, April 05, 2007 12:11 AM > > To: fop-users@xmlgraphics.apache.org > > Subject: Re: Convert InputSource into a Character array > > > > I don't understand what you're trying to do. Maybe you should > > explain that before going into technical details. > > > > On 04.04.2007 06:08:53 Harshini Madurapperuma wrote: > > > Hi All; > > > > > > In fop Driver class there is a method called > > > > > > public synchronized void render(XMLReader parser, InputSource source) > > > throws FOPException { > > > > > > } > > > > > > Is there a way to convert that InputSource "source" back into a > > > character array within that render class? I tried to do it by this > > > way but it throws a "Stream Closed" Exception. > > > ------------------------------------------------------------------ > > > -- > > > -- > > > ------ > > > -- > > > if (source.getCharacterStream() != null) { > > > BufferedReader reader = new > > > BufferedReader(source.getCharacterStream()); > > > CharArrayWriter writer=new CharArrayWriter(); > > > int i=-1; > > > while ((i=reader.read())!=-1) > > > { > > > writer.write(i); > > > } > > > reader.close(); > > > writer.close(); > > > } > > > ------------------------------------------------------------------ > > > -- > > > -- > > > ------ > > > ---- > > > EXCEPTION--------------------------------------------------------- > > > -- > > > -- > > > ------ > > > ---- > > > > > > java.io.IOException: Stream closed at > > > java.io.CharArrayReader.ensureOpen(CharArrayReader.java:65) at > > > java.io.CharArrayReader.read(CharArrayReader.java:95) at > > > java.io.BufferedReader.fill(BufferedReader.java:136) at > > > java.io.BufferedReader.read(BufferedReader.java:157) at > > > org.apache.fop.apps.Driver.render(Driver.java:557) > > > ------------------------------------------------------------------ > > > -- > > > -- > > > ------ > > > ----- > > > > > > I'm using java as the language. Pls ur help will be greatly > > > appreciated Thanx Harshini. > > > > > > Jeremias Maerki > > > > > > -------------------------------------------------------------------- > > - To unsubscribe, e-mail: > > fop-users-unsubscribe@xmlgraphics.apache.org > > For additional commands, e-mail: > > fop-users-help@xmlgraphics.apache.org > > > > -------------------------------------------------------------------- > > - To unsubscribe, e-mail: > > fop-users-unsubscribe@xmlgraphics.apache.org > > For additional commands, e-mail: > > fop-users-help@xmlgraphics.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org