Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: XML-encoding

Re: XML-encoding

From: Frank <fbortel_at_home.nl>
Date: Thu, 12 Dec 2002 21:52:04 +0100
Message-ID: <3DF8F6F4.3010407@home.nl>


Sofia wrote:
> Dear friends, I was wondering if you could help me.
>
> I am using sys_xmlgen to get xml
>
> --> from an Oracle 9i db which has an ISO-8859-7 encoding
>
> --> to a java class (running in the Jdeveloper local oc4j)
>
> Whilst parsing the XML in my java class, an 'invalid UTF encoding'
> exception rises from the parser.
>
> It seems as if the parser is quite certain the text is in UTF format. How
> could I possibly explicitly define the output to be in ISO-8859-7?
>
> I am attaching an extract from my code. Any ideas much welcomed.
>
> Sofia
>
> ----------snip,snip--8X-----------------------------------------------
>
>
>
> // Load Oracle driver
> DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
>
> // Connect to the local database (using OCI or thin driver)
> Connection conn =
> DriverManager.getConnection("jdbc:oracle:thin:@buble:1521:corfu", "scott",
> "tiger" );
>
> PreparedStatement ps = conn.prepareStatement("select p.doc.getclobval() s
> from v_trim p where p.trimhno=1 and p.kodikos_mis=60620 and etos=2005");
> ResultSet rs = ps.executeQuery();
>
> InputStreamReader to_return = null;
> rs.next();
> to_return = new InputStreamReader(rs.getAsciiStream("s"), "ISO-8859-7" );
>
> rs.close();
> ps.close();
>
> int xml_sch = 0;
> StringBuffer sBuf = new StringBuffer();
> while( (xml_sch = to_return.read( )) != -1 )
> sBuf.append( (char)xml_sch );
>
> InputStream i_s = new StringBufferInputStream(sBuf.toString());
> DOMParser par = new DOMParser();
> InputSource is = new InputSource( i_s );
> is.setEncoding("ISO-8859-7");
> par.parse( is ); <---- problem arises here
>
>
>
>

XML will use UTF (in order to make sure it can talk to and from different charactersets). Threat as UTF8 and you will be fine

Hth, hand, grtz, Frank Received on Thu Dec 12 2002 - 14:52:04 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US