Index: java/src/org/apache/xindice/tools/command/AddDocument.java =================================================================== RCS file: /home/cvspublic/xml-xindice/java/src/org/apache/xindice/tools/command/AddDocument.java,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 AddDocument.java --- java/src/org/apache/xindice/tools/command/AddDocument.java 6 Dec 2001 19:33:57 -0000 1.1.1.1 +++ java/src/org/apache/xindice/tools/command/AddDocument.java 25 Feb 2002 10:37:46 -0000 @@ -73,6 +73,11 @@ import org.w3c.dom.*; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + /** * AddDocument.java is designed to let the user add Single Documents * and/or Multiple Documents to an existing Collection or Nested Collection @@ -111,21 +116,21 @@ return false; } - // Open a new file input stream and read in the document + // Parse in XML using JAXP libraries + StringWriter inString = new StringWriter(); File file = new File((String) table.get("filePath")); - FileInputStream insr = new FileInputStream(file); - - byte[] fileBuffer = new byte[(int) file.length()]; - - insr.read(fileBuffer); - insr.close(); + Transformer tf + = TransformerFactory.newInstance().newTransformer(); + tf.transform(new StreamSource(new FileInputStream(file)), + new StreamResult(inString)); + // Create the XMLResource and store the document XMLResource resource = (XMLResource) col.createResource((String) table.get("nameOf"), "XMLResource"); - resource.setContent(new String(fileBuffer)); + resource.setContent(inString.toString()); col.storeResource(resource); System.out.println("Added document " + table.get("collection") + "/" + Index: java/src/org/apache/xindice/tools/command/RetrieveDocument.java =================================================================== RCS file: /home/cvspublic/xml-xindice/java/src/org/apache/xindice/tools/command/RetrieveDocument.java,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 RetrieveDocument.java --- java/src/org/apache/xindice/tools/command/RetrieveDocument.java 6 Dec 2001 19:33:57 -0000 1.1.1.1 +++ java/src/org/apache/xindice/tools/command/RetrieveDocument.java 25 Feb 2002 10:37:46 -0000 @@ -118,7 +118,7 @@ System.out.println("Writing..."); - out.write(documentstr.getBytes()); + out.write(documentstr.getBytes("utf-8")); out.close(); System.out.println("Wrote file " + table.get("filePath") );