Return-Path: X-Original-To: apmail-ws-dev-archive@www.apache.org Delivered-To: apmail-ws-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B18B39B9D for ; Tue, 25 Oct 2011 18:29:22 +0000 (UTC) Received: (qmail 58333 invoked by uid 500); 25 Oct 2011 18:29:22 -0000 Delivered-To: apmail-ws-dev-archive@ws.apache.org Received: (qmail 58118 invoked by uid 500); 25 Oct 2011 18:29:21 -0000 Mailing-List: contact dev-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ws.apache.org Delivered-To: mailing list dev@ws.apache.org Received: (qmail 58111 invoked by uid 99); 25 Oct 2011 18:29:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Oct 2011 18:29:21 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of andreas.veithen@gmail.com designates 209.85.216.170 as permitted sender) Received: from [209.85.216.170] (HELO mail-qy0-f170.google.com) (209.85.216.170) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Oct 2011 18:29:15 +0000 Received: by qyk32 with SMTP id 32so5350739qyk.1 for ; Tue, 25 Oct 2011 11:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=Y9EjfvPL/Qe6eikxXv0cNWtiCbkT/yaxiJfyuFv5wvc=; b=hk+Xe9xdzJaez0WF2R8QPVOtg6TjmRGJGXm90ES1ToB/7LG6DE5w8V1Pc04a0WoXM3 sTpGkKKp2oZ35avCfcFbze52GpPzD9dw155ka4gimjSNrHQJM96V5uAl5sOCV3CgS414 Nr7s2pRBbw6pVfERwnh7gGeeqkTRecy6sxlS4= Received: by 10.229.74.79 with SMTP id t15mr4698888qcj.153.1319567334149; Tue, 25 Oct 2011 11:28:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.225.211 with HTTP; Tue, 25 Oct 2011 11:28:33 -0700 (PDT) In-Reply-To: References: From: Andreas Veithen Date: Tue, 25 Oct 2011 20:28:33 +0200 Message-ID: Subject: Re: Read larger text content using axiom To: dev@ws.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Jasintha, The sample code doesn't really show what you are trying to achieve. Obviously you wouldn't use Axiom to read the content of a file into a String, so what is the actual use case? Andreas On Tue, Oct 25, 2011 at 06:48, Jasintha Dasanayaka wr= ote: > =A0Hi Andreas > > =A0According to you Answer in issue[1] I have modified the method as foll= ows > is this the correct way to do this If not could you please suggest a corr= ect > way > > > > private static String readFile(String file) throws IOException, > XMLStreamException { > > =A0=A0=A0 =A0=A0=A0 FileInputStream fin =3D new FileInputStream(file); > =A0=A0=A0 =A0=A0=A0 OMFactory factory =3D OMAbstractFactory.getOMFactory(= ); > =A0=A0=A0=A0=A0=A0=A0 String charSetEnc =3D BuilderUtil.getCharSetEncodin= g("text/plain"); > =A0=A0=A0=A0=A0=A0=A0 QName wrapperQName =3D BaseConstants.DEFAULT_TEXT_W= RAPPER; > =A0=A0=A0=A0=A0=A0=A0 Reader reader; > =A0=A0=A0=A0=A0=A0=A0 try { > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 reader =3D new InputStreamReader(fin, c= harSetEnc); > =A0=A0=A0=A0=A0=A0=A0 } catch (UnsupportedEncodingException ex) { > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 throw new AxisFault("Unsupported encodi= ng: " + charSetEnc, ex); > =A0=A0=A0=A0=A0=A0=A0 } > =A0=A0=A0=A0=A0=A0=A0 OMElement om =3D=A0 new OMSourcedElementImpl(wrappe= rQName, factory, > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 new WrappedTextNodeOMDataSo= urceFromReader(wrapperQName, > reader)); > =A0=A0=A0=A0=A0=A0=A0 om.serialize(System.out); > > =A0 =A0 =A0=A0 /*=A0 before modify > =A0=A0=A0=A0=A0=A0 OMNode textNode =3D om.getFirstOMChild(); > =A0=A0=A0=A0=A0=A0=A0 OMText text =3D (OMText) textNode; > =A0=A0=A0 =A0=A0=A0 return text.getText(); > =A0=A0=A0=A0=A0 */ > > =A0=A0=A0=A0=A0=A0=A0 StringBuffer buffer =3D new StringBuffer(); > =A0=A0=A0=A0=A0=A0=A0 Iterator iterator =3D om.getChildren(); > =A0=A0=A0=A0=A0=A0=A0 while(iterator.hasNext()){ > =A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0 OMText text =3D (OMText) iterator.next(); > =A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0 buffer.append(text.getText()); > =A0=A0=A0=A0=A0=A0=A0 } > > =A0=A0=A0=A0=A0=A0=A0 return buffer.toString(); > > =A0=A0=A0 } > > > =A0Thanks & Regards > =A0/Jasintha > > [1]-https://issues.apache.org/jira/browse/AXIOM-395 > > -- > Thanks & Regards > > Jasintha Dasanayake > Software Engineer. > > WSO2 Inc,|http://wso2.com > lean . enterprise . middleware > > mobile +94 772 916 596 , > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org For additional commands, e-mail: dev-help@ws.apache.org