Gianugo Rabellino wrote:



Not working yet, but probably almost there. I checked and it seems like my code modifications succeed in a valid document insertion, but still retrieval fails. I'll clean up a bit my messy attempts and I'll send you a diff: maybe that we both forgot some quirk elsewhere in the source.


YAY! Now it works. :-)

Attached is the diff file, please review it carefully, I might have done even too much in converting Strings and encoding (hopefully properly) stuff. But now, in my setup, it works like a charm. I haven't tested it on W2K, will do it tomorrow.

I'm an happy man again: my site will go in production tomorrow, my flu is almost over, I've been hacking for a couple of days and learning about XIndice internals... life is beautiful. :)

Thaks again Tom for bearing with me,

--
Gianugo Rabellino



Index: java/src/org/apache/xindice/client/corba/EncodedBufferConverter.java
===================================================================
RCS file: 
/home/cvspublic/xml-xindice/java/src/org/apache/xindice/client/corba/EncodedBufferConverter.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 EncodedBufferConverter.java
--- java/src/org/apache/xindice/client/corba/EncodedBufferConverter.java        
6 Dec 2001 19:33:53 -0000       1.1.1.1
+++ java/src/org/apache/xindice/client/corba/EncodedBufferConverter.java        
9 Jan 2002 23:16:24 -0000
@@ -121,11 +121,12 @@
       * Parses the buffer into a Document.
       */
    private static Document getDocument(EncodedBuffer buffer) {
-      String buf = new String(buffer.buf);
 
       try {
+        String buf = new String(buffer.buf, "UTF-8");
          // Parse the buffer
-         return DOMParser.toDocument(buf);
+        // System.err.println(buf);
+         return DOMParser.toDocument(buffer.buf);
       }
       catch ( Exception e ) {
          //org.apache.xindice.Debug.println("Error Converting Buffer '" + buf 
+ "'");
Index: java/src/org/apache/xindice/client/xmldb/CollectionImpl.java
===================================================================
RCS file: 
/home/cvspublic/xml-xindice/java/src/org/apache/xindice/client/xmldb/CollectionImpl.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 CollectionImpl.java
--- java/src/org/apache/xindice/client/xmldb/CollectionImpl.java        6 Dec 
2001 19:33:53 -0000       1.1.1.1
+++ java/src/org/apache/xindice/client/xmldb/CollectionImpl.java        9 Jan 
2002 23:16:24 -0000
@@ -394,7 +394,7 @@
             resource = new XMLResourceImpl(id, this, s, buffer.buf);
          }
          else
-            resource = new XMLResourceImpl(id, this, new String(buffer.buf));
+            resource = new XMLResourceImpl(id, this, new String(buffer.buf, 
"UTF-8"));
       }
       catch (APIException e) {
          if (e.faultCode == FaultCodes.COL_DOCUMENT_NOT_FOUND) {
@@ -501,7 +501,7 @@
             throw new XMLDBException(ErrorCodes.INVALID_RESOURCE);
          }
          
-         buffer.buf = content.getBytes();
+         buffer.buf = content.getBytes("UTF-8");
          buffer.stamp = -1;
 
          String id = resource.getId();
Index: 
java/src/org/apache/xindice/client/xmldb/services/XPathQueryServiceImpl.java
===================================================================
RCS file: 
/home/cvspublic/xml-xindice/java/src/org/apache/xindice/client/xmldb/services/XPathQueryServiceImpl.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 XPathQueryServiceImpl.java
--- 
java/src/org/apache/xindice/client/xmldb/services/XPathQueryServiceImpl.java    
    6 Dec 2001 19:33:54 -0000       1.1.1.1
+++ 
java/src/org/apache/xindice/client/xmldb/services/XPathQueryServiceImpl.java    
    9 Jan 2002 23:16:24 -0000
@@ -231,7 +231,7 @@
             result = new XMLResourceImpl("", collection, s, buffer.buf);
          }
          else
-            result = new XMLResourceImpl("", collection, new 
String(buffer.buf));
+            result = new XMLResourceImpl("", collection, new 
String(buffer.buf, "UTF-8"));
       }
       catch (Exception e) {
          result = null;
Index: 
java/src/org/apache/xindice/client/xmldb/services/XUpdateQueryServiceImpl.java
===================================================================
RCS file: 
/home/cvspublic/xml-xindice/java/src/org/apache/xindice/client/xmldb/services/XUpdateQueryServiceImpl.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 XUpdateQueryServiceImpl.java
--- 
java/src/org/apache/xindice/client/xmldb/services/XUpdateQueryServiceImpl.java  
    6 Dec 2001 19:33:54 -0000       1.1.1.1
+++ 
java/src/org/apache/xindice/client/xmldb/services/XUpdateQueryServiceImpl.java  
    9 Jan 2002 23:16:24 -0000
@@ -102,7 +102,7 @@
 
       try {
          EncodedBuffer buffer = col.queryCollection("XUpdate", commands, 
EmptyNamedVals, -1);
-         return new XMLResourceImpl("", collection, new String(buffer.buf));
+         return new XMLResourceImpl("", collection, new String(buffer.buf, 
"UTF-8"));
       }
       catch (Exception e) {
          throw FaultCodes.createXMLDBException(e);
@@ -130,7 +130,7 @@
 
       try {
          EncodedBuffer buffer = col.queryDocument("XUpdate", commands, 
EmptyNamedVals, id, -1);
-         return new XMLResourceImpl("", collection, new String(buffer.buf));
+         return new XMLResourceImpl("", collection, new String(buffer.buf, 
"UTF-8"));
       }
       catch (Exception e) {
          throw FaultCodes.createXMLDBException(e);
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  9 Jan 2002 
23:16:25 -0000
@@ -124,8 +124,7 @@
          XMLResource resource =
                (XMLResource) col.createResource((String) table.get("nameOf"),
                   "XMLResource");
-
-         resource.setContent(new String(fileBuffer));
+         resource.setContent(new String(fileBuffer, "UTF-8"));
          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     9 Jan 
2002 23:16:25 -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") );

Reply via email to