You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2019/04/22 23:27:01 UTC

[GitHub] [cxf] jpoje-gtri commented on a change in pull request #543: [CXF-8025]: Fix Wrapper Style for multilevel xsd:extension elements

jpoje-gtri commented on a change in pull request #543: [CXF-8025]: Fix Wrapper Style for multilevel xsd:extension elements
URL: https://github.com/apache/cxf/pull/543#discussion_r277471877
 
 

 ##########
 File path: tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
 ##########
 @@ -368,32 +366,46 @@ public static Node cloneNode(Document document, Node node, boolean deep) throws
 
         XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
 
-        qnames.addAll(createWrappedElements(seq));
+        List<WrapperElement> qnames = createWrappedElements(seq);
 
         //If it's extension
         if (seq == null && type.getContentModel() != null) {
+            qnames.addAll(createWrappedElementsFromExtension(schema, type));
+        }
 
-            XmlSchemaContent xmlSchemaConent = type.getContentModel().getContent();
-            if (xmlSchemaConent instanceof XmlSchemaComplexContentExtension) {
-                XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)type
-                    .getContentModel().getContent();
-                QName baseTypeName = extension.getBaseTypeName();
-                XmlSchemaType schemaType = schema.getTypeByQName(baseTypeName);
-                if (schemaType instanceof XmlSchemaComplexType) {
-                    XmlSchemaComplexType complexType = (XmlSchemaComplexType)schemaType;
-                    if (complexType.getParticle() instanceof XmlSchemaSequence) {
-                        seq = (XmlSchemaSequence)complexType.getParticle();
-                        qnames.addAll(createWrappedElements(seq));
-                    }
-                }
+        return qnames;
+    }
 
-                if (extension.getParticle() instanceof XmlSchemaSequence) {
-                    XmlSchemaSequence xmlSchemaSeq = (XmlSchemaSequence)extension.getParticle();
-                    qnames.addAll(createWrappedElements(xmlSchemaSeq));
-                }
+    private static List<WrapperElement> createWrappedElementsFromExtension(SchemaCollection schema,
+                                                                           XmlSchemaComplexType type) {
+        List<WrapperElement> qnames = new ArrayList<>();
+
+        XmlSchemaContent schemaContent = type.getContentModel().getContent();
+        if (!(schemaContent instanceof XmlSchemaComplexContentExtension)) {
+            return qnames;
+        }
+
+        XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)schemaContent;
+        QName baseTypeName = extension.getBaseTypeName();
+        XmlSchemaType baseType = schema.getTypeByQName(baseTypeName);
+
+        if (baseType instanceof XmlSchemaComplexType) {
+            XmlSchemaComplexType complexBaseType = (XmlSchemaComplexType)baseType;
+
+            if (complexBaseType.getParticle() == null && complexBaseType.getContentModel() != null) {
+                // continue up the extension ladder
+                qnames.addAll(createWrappedElementsFromExtension(schema, complexBaseType));
 
 Review comment:
   Seems like a good thing to handle.  If there is interest in this PR's approach from a high level, I don't mind shepherding it to completion.  I was primarily making sure a test case was available but if the fix is accepted that's awesome too.  If this approach is on the right track please give me some feedback for the questions below and I'll get a tweaked commit up this week probably.
   
   Questions:
   1. Is there a CXF best practice for handling recursive traversals?  A brief search shows something similar in DepthRestrictingStreamReader, with hardcoded limits throwing a custom exception when max depth is exceeded.
   1. What kind of limit makes sense here?
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services