[CXF-5800] SchemaValidation of RPC/Lit endpoints fails if data has attributes


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b1b5ab5d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b1b5ab5d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b1b5ab5d

Branch: refs/heads/3.0.x-fixes
Commit: b1b5ab5d30f78837c371b8927d7684eefb8e86e5
Parents: 8c8bbac
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu Mar 23 12:42:23 2017 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu Mar 23 13:15:37 2017 -0400

----------------------------------------------------------------------
 .../org/apache/cxf/jaxb/JAXBEncoderDecoder.java     | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b1b5ab5d/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
----------------------------------------------------------------------
diff --git 
a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java 
b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
index b7b0478..341d65e 100644
--- 
a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
+++ 
b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
@@ -102,6 +102,7 @@ import org.apache.ws.commons.schema.constants.Constants;
 public final class JAXBEncoderDecoder {
     private static final class AddXSITypeStreamReader extends 
StreamReaderDelegate {
         private boolean first = true;
+        private int offset = 1;
         private final QName typeQName;
 
         private AddXSITypeStreamReader(XMLStreamReader reader, QName 
typeQName) {
@@ -110,42 +111,42 @@ public final class JAXBEncoderDecoder {
         }
 
         public int getAttributeCount() {
-            return super.getAttributeCount() + (first ? 1 : 0);
+            return super.getAttributeCount() + offset;
         }
 
         public String getAttributeLocalName(int index) {
             if (first && index == 0) {
                 return "type";
             }
-            return super.getAttributeLocalName(index - 1);
+            return super.getAttributeLocalName(index - offset);
         }
 
         public QName getAttributeName(int index) {
             if (first && index == 0) {
                 return new QName(Constants.URI_2001_SCHEMA_XSI, "type");
             }
-            return super.getAttributeName(index - 1);
+            return super.getAttributeName(index - offset);
         }
 
         public String getAttributeNamespace(int index) {
             if (first && index == 0) {
                 return Constants.URI_2001_SCHEMA_XSI;
             }
-            return super.getAttributeNamespace(index - 1);
+            return super.getAttributeNamespace(index - offset);
         }
 
         public String getAttributePrefix(int index) {
             if (first && index == 0) {
                 return "xsi";
             }
-            return super.getAttributePrefix(index - 1);
+            return super.getAttributePrefix(index - offset);
         }
 
         public String getAttributeType(int index) {
             if (first && index == 0) {
                 return "#TEXT";
             }
-            return super.getAttributeType(index - 1);
+            return super.getAttributeType(index - offset);
         }
 
         public String getAttributeValue(int index) {
@@ -156,11 +157,12 @@ public final class JAXBEncoderDecoder {
                 }
                 return pfx + ":" + typeQName.getLocalPart();
             }
-            return super.getAttributeValue(index);
+            return super.getAttributeValue(index - offset);
         }
 
         public int next()  throws XMLStreamException {
             first = false;
+            offset = 0;
             return super.next();
         }
 

Reply via email to