cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r751973 - in /cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans: DataReaderImpl.java DataWriterImpl.java
Date Tue, 10 Mar 2009 03:58:14 GMT
Author: ningjiang
Date: Tue Mar 10 03:58:13 2009
New Revision: 751973

URL: http://svn.apache.org/viewvc?rev=751973&view=rev
Log:
CXF-2099 added the supporting of XMLSchema vaildation in XMLBeans databinding

Modified:
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java

Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java?rev=751973&r1=751972&r2=751973&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
Tue Mar 10 03:58:13 2009
@@ -31,17 +31,20 @@
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.databinding.DataReaderValidation2;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlAnySimpleType;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
 
 
-public class DataReaderImpl implements DataReader<XMLStreamReader> {
+public class DataReaderImpl implements DataReader<XMLStreamReader> , DataReaderValidation2
{
     private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
+    private XmlSchemaCollection schemas;
     
     public DataReaderImpl() {
     }
@@ -68,13 +71,17 @@
         for (Class<?> c : cls) {
             if ("Factory".equals(c.getSimpleName())) {
                 try {
+                    
                     SchemaType st = (SchemaType)part.getProperty(SchemaType.class.getName());
                     XmlOptions options = new XmlOptions();
+                    if (schemas != null) {
+                        options.setValidateOnSet();
+                    }
                     if (st != null && !st.isDocumentType() && !isOutClass)
{
                         options.setLoadReplaceDocumentElement(null);
                     }
                     Method meth = c.getMethod("parse", XMLStreamReader.class, XmlOptions.class);
-                    obj = meth.invoke(null, reader, options);
+                    obj = meth.invoke(null, reader, options);                    
                     break;
                 } catch (Exception e) {
                     e.printStackTrace();
@@ -138,4 +145,8 @@
     public void setSchema(Schema s) {
     }
 
+    public void setSchema(XmlSchemaCollection validationSchemas) {
+        this.schemas = validationSchemas; 
+    }
+
 }

Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java?rev=751973&r1=751972&r2=751973&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
Tue Mar 10 03:58:13 2009
@@ -47,6 +47,7 @@
 
 public class DataWriterImpl implements DataWriter<XMLStreamWriter> {
     private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
+    private Schema schema;
     
     public DataWriterImpl() {
     }
@@ -67,6 +68,9 @@
                         try {
                             SchemaType st = (SchemaType)part.getProperty(SchemaType.class.getName());
                             XmlOptions options = new XmlOptions();
+                            if (schema != null) {
+                                options.setValidateOnSet();
+                            }
                             if (!st.isDocumentType()) {
                                 options.setLoadReplaceDocumentElement(null);
                             }
@@ -84,6 +88,9 @@
             if (obj != null
                 || !(part.getXmlSchema() instanceof XmlSchemaElement)) {
                 XmlOptions options = new XmlOptions();
+                if (schema != null) {
+                    options.setValidateOnSet();
+                }
                 XMLStreamReader reader;
                 if (obj instanceof XmlObjectBase) {
                     XmlObjectBase source = (XmlObjectBase)obj;
@@ -140,6 +147,7 @@
     public void setProperty(String key, Object value) {
     }
 
-    public void setSchema(Schema s) {
+    public void setSchema(Schema schema) {
+        this.schema = schema;
     }
 }



Mime
View raw message