Author: dims
Date: Thu Jun 21 20:31:23 2007
New Revision: 549693

URL: http://svn.apache.org/viewvc?view=rev&rev=549693
Log:
Get XmlSchema to work somewhat better in DOM2 (See Stack trace in AXIS2-2814)

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

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?view=diff&rev=549693&r1=549692&r2=549693
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
 Thu Jun 21 20:31:23 2007
@@ -23,6 +23,7 @@
 import org.apache.ws.commons.schema.utils.NodeNamespaceContext;
 import org.apache.ws.commons.schema.utils.TargetNamespaceValidator;
 import org.apache.ws.commons.schema.utils.XDOMUtil;
+import org.apache.ws.commons.schema.utils.DOMUtil;
 import org.w3c.dom.*;
 import org.xml.sax.InputSource;
 
@@ -77,7 +78,7 @@
     XmlSchema build(Document doc, String uri, ValidationEventHandler veh) {
         Element schemaEl = doc.getDocumentElement();
         XmlSchema xmlSchema = handleXmlSchemaElement(schemaEl, uri);
-        xmlSchema.setInputEncoding(doc.getInputEncoding());
+        xmlSchema.setInputEncoding(DOMUtil.getInputEncoding(doc));
         return xmlSchema;
     }
 

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java?view=diff&rev=549693&r1=549692&r2=549693
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
 Thu Jun 21 20:31:23 2007
@@ -22,6 +22,7 @@
 import org.apache.ws.commons.schema.resolver.URIResolver;
 import org.apache.ws.commons.schema.utils.NamespacePrefixList;
 import org.apache.ws.commons.schema.utils.TargetNamespaceValidator;
+import org.apache.ws.commons.schema.utils.DOMUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -341,7 +342,7 @@
     public XmlSchema read(Element elem) {
         SchemaBuilder builder = new SchemaBuilder(this, null);
         XmlSchema xmlSchema = builder.handleXmlSchemaElement(elem, null);
-        xmlSchema.setInputEncoding(elem.getOwnerDocument().getInputEncoding());
+        
xmlSchema.setInputEncoding(DOMUtil.getInputEncoding(elem.getOwnerDocument()));
         return xmlSchema;
     }
 
@@ -358,7 +359,7 @@
     public XmlSchema read(Element elem, String uri) {
         SchemaBuilder builder = new SchemaBuilder(this, null);
         XmlSchema xmlSchema = builder.handleXmlSchemaElement(elem, null);
-        xmlSchema.setInputEncoding(elem.getOwnerDocument().getInputEncoding());
+        
xmlSchema.setInputEncoding(DOMUtil.getInputEncoding(elem.getOwnerDocument()));
         return xmlSchema;
     }
 

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java?view=diff&rev=549693&r1=549692&r2=549693
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
 Thu Jun 21 20:31:23 2007
@@ -18,6 +18,9 @@
 
 import org.w3c.dom.*;
 
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
 /**
  * Some useful utility methods.
  * This class was modified in Xerces2 with a view to abstracting as
@@ -580,5 +583,14 @@
     // return the namespace URI
     public static String getNamespaceURI(Node node) {
         return node.getNamespaceURI();
+    }
+
+    public static String getInputEncoding(Document doc) {
+        try {
+            Method m = Document.class.getMethod("getInputEncoding", new 
Class[]{});
+            return (String) m.invoke(doc, new Object[]{});
+        } catch (Exception e) {
+            return "UTF-8";
+        }
     }
 } // class XUtil



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

Reply via email to