[ http://issues.apache.org/jira/browse/XMLBEANS-209?page=comments#action_12330733 ]
Koyama Hiroshi commented on XMLBEANS-209: ----------------------------------------- It is as follows. org.sssg.schema.ManuscriptDocument class is generated by XMLBeans. doc.save(os); throws Exception. ManuscriptDocument has base64 data, but I do not know whether it is influential. --------------------------------------------------------------------------------------------------- import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import org.sssg.schema.ManuscriptDocument; import org.apache.xmlbeans.XmlException; public class Sample { private ManuscriptDocument doc; public void save(String fileName) { OutputStreamWriter os = null; try { os = new OutputStreamWriter(new FileOutputStream(fileName),"UTF-8"); doc.save(os); os.flush(); } catch (IOException e) { System.out.println("write error"); } finally { if (os != null) { try { os.close(); } catch (IOException e) { System.out.println("can't close "+fileName); } } } } public void importXml(String fileName) { doc = null; try { doc = ManuscriptDocument.Factory.parse(new File(fileName)); } catch (IOException e) { System.out.println("can't find "+fileName); } catch (XmlException e) { System.out.println("XML syntax error : "+fileName); } } public static void main(String args[]) { Sample list = new Sample(); list.importXml("sample.xml"); list.save("saved.xml"); } } > Saver$TextSaver.replace method throws java.lang.ArrayIndexOutOfBoundsException > ------------------------------------------------------------------------------ > > Key: XMLBEANS-209 > URL: http://issues.apache.org/jira/browse/XMLBEANS-209 > Project: XMLBeans > Type: Bug > Versions: Version 2 > Environment: Java2 RE 1.4 and Java2 RE 5.0 > Reporter: Koyama Hiroshi > > Stacktrace is as follows. > java.lang.ArrayIndexOutOfBoundsException > at java.lang.System.arraycopy(Native Method) > at > org.apache.xmlbeans.impl.store.Saver$TextSaver.replace(Saver.java:1438) > at > org.apache.xmlbeans.impl.store.Saver$TextSaver.entitizeContent(Saver.java:1269) > (snip) > I checked each variables. > 1438: System.arraycopy( _buf, i, _buf, i + dCch, _in - i ); // i:16358 > _in:16381 dcCh:4 _buf.length:16384 > I think _buf has not enough size. > So, I changed source as follows. > 1438: if (_buf.length < _in+dCch+_in-i) i = resize( dCch, i); > 1439: System.arraycopy( _buf, i, _buf, i + dCch, _in - i ); > This is not good patch, but I can save xml data. > regards. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]