Author: ajith
Date: Mon Oct 22 07:13:57 2007
New Revision: 587105

URL: http://svn.apache.org/viewvc?rev=587105&view=rev
Log:
1. Fixing issue  WSCOMMONS-260. The problem seemed to be a logical expression 
error in the prevoius code but just to be on the safe side added the encoding 
flag to the streamwriter as well (according to the suggestion made by Grzegorz 
- the reporter)

Modified:
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java?rev=587105&r1=587104&r2=587105&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
 Mon Oct 22 07:13:57 2007
@@ -29,11 +29,7 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.io.ByteArrayInputStream;
+import java.io.*;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -199,7 +195,19 @@
      * @param out - the output stream to write to
      */
     public void write(OutputStream out) {
-        write(new OutputStreamWriter(out));
+        if (this.inputEncoding!= null &&
+                !"".equals(this.inputEncoding)){
+            try {
+                write(new OutputStreamWriter(out,this.inputEncoding));
+            } catch (UnsupportedEncodingException e) {
+                //log the error and just write it without the encoding
+                
+                write(new OutputStreamWriter(out));
+            }
+        }else{
+            write(new OutputStreamWriter(out));
+        }
+
     }
 
     /**
@@ -208,7 +216,18 @@
      * @param options -  a map of options
      */
     public void write(OutputStream out, Map options) {
-        write(new OutputStreamWriter(out),options);
+        if (this.inputEncoding!= null &&
+                !"".equals(this.inputEncoding)){
+            try {
+                 write(new OutputStreamWriter(out,this.inputEncoding),options);
+            } catch (UnsupportedEncodingException e) {
+                //log the error and just write it without the encoding
+                write(new OutputStreamWriter(out));
+            }
+        }else{
+             write(new OutputStreamWriter(out),options);
+        }
+
     }
 
     /**
@@ -263,16 +282,16 @@
             Result result = new StreamResult(out);
             javax.xml.transform.Transformer tr = trFac.newTransformer();
 
-            //use the input encoding if there is one one
+            //use the input encoding if there is one
             if (schema.inputEncoding!= null &&
-                    "".equals(schema.inputEncoding)){
+                    !"".equals(schema.inputEncoding)){
                 tr.setOutputProperty(OutputKeys.ENCODING,schema.inputEncoding);
             }
 
             //let these be configured from outside  if any is present
             //Note that one can enforce the encoding by passing the necessary
             //property in options
-            
+
             if (options==null){
                 options = new HashMap();
                 loadDefaultOptions(options);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to