[ 
https://issues.apache.org/jira/browse/CXF-4017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Kulp resolved CXF-4017.
------------------------------

       Resolution: Fixed
    Fix Version/s: 2.5.2
                   2.4.6
    
> SchemaCollection.addCrossImports handles only XmlSchemaSequence instead of 
> all XmlSchemaGroupParticle
> -----------------------------------------------------------------------------------------------------
>
>                 Key: CXF-4017
>                 URL: https://issues.apache.org/jira/browse/CXF-4017
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.4.4
>            Reporter: Benoit Lacelle
>            Assignee: Daniel Kulp
>             Fix For: 2.4.6, 2.5.2
>
>
> This issues seems to be the same as: 
> http://cxf.547215.n5.nabble.com/validation-error-td5101800.html
> In my context, it happends only when my WebMethod interface holds an Exception
> It looks like 
> org.apache.cxf.common.xmlschema.SchemaCollection.addCrossImportsType has been 
> written for XmlSchemaSequence only, while it could be called on any 
> XmlSchemaGroupParticle.
> Then, I adapted the code in SchemaCollection.addCrossImportsType to the three 
> specializations of XmlSchemaGroupParticle and it seems to work properly.
> {code}
>     private static final XmlSchemaChoice EMPTY_CHOICE = new XmlSchemaChoice();
>     private static final XmlSchemaAll EMPTY_ALL = new XmlSchemaAll();
> ...
> private void addCrossImportsType(XmlSchema schema, XmlSchemaType schemaType) {
>         // the base type might cross schemas.
>         if (schemaType instanceof XmlSchemaComplexType) {
>             XmlSchemaComplexType complexType = 
> (XmlSchemaComplexType)schemaType;
>             XmlSchemaUtils.addImportIfNeeded(schema, 
> complexType.getBaseSchemaTypeName());
>             addCrossImports(schema, complexType.getContentModel());
>             addCrossImportsAttributeList(schema, complexType.getAttributes());
>             // could it be a choice or something else?
>             
>             // HACK QFS
>             if (complexType.getParticle() instanceof XmlSchemaChoice) {
>               XmlSchemaChoice choice = null;
>                               // XmlSchemaSequence sequence = 
> XmlSchemaUtils.getSequence(complexType);
>                 {
>                     XmlSchemaParticle particle = complexType.getParticle();
>                     XmlSchemaChoice localChoice = null;
>                     if (particle == null) {
>                         // the code that uses this wants to iterate. An empty 
> one is more useful than
>                         // a null pointer, and certainly an exception.
>                       localChoice = EMPTY_CHOICE;
>                     } else {
>                         try {
>                               localChoice = (XmlSchemaChoice) particle;
>                         } catch (ClassCastException cce) {
>                               
> XmlSchemaUtils.unsupportedConstruct("NON_CHOICE_PARTICLE", complexType);
>                         }
>                     }
>                     choice = localChoice;
>                 }
>                 
>                 //addCrossImportsSequence(schema, sequence);
>                 {
>                     for (XmlSchemaObject seqMember : choice.getItems()) {
>                         if (seqMember instanceof XmlSchemaElement) {
>                             addElementCrossImportsElement(schema, 
> (XmlSchemaElement)seqMember);
>                         }
>                     }
>                 }
>             } else if (complexType.getParticle() instanceof XmlSchemaAll) {
>               XmlSchemaAll all = null;
>                               // XmlSchemaSequence sequence = 
> XmlSchemaUtils.getSequence(complexType);
>                 {
>                     XmlSchemaParticle particle = complexType.getParticle();
>                     XmlSchemaAll localAll = null;
>                     if (particle == null) {
>                         // the code that uses this wants to iterate. An empty 
> one is more useful than
>                         // a null pointer, and certainly an exception.
>                       localAll = EMPTY_ALL;
>                     } else {
>                         try {
>                               localAll = (XmlSchemaAll) particle;
>                         } catch (ClassCastException cce) {
>                               
> XmlSchemaUtils.unsupportedConstruct("NON_ALL_PARTICLE", complexType);
>                         }
>                     }
>                     all = localAll;
>                 }
>                 
>                 //addCrossImportsSequence(schema, sequence);
>                 {
>                     for (XmlSchemaObject seqMember : all.getItems()) {
>                         if (seqMember instanceof XmlSchemaElement) {
>                             addElementCrossImportsElement(schema, 
> (XmlSchemaElement)seqMember);
>                         }
>                     }
>                 }
>             } else {
>                 XmlSchemaSequence sequence = 
> XmlSchemaUtils.getSequence(complexType);
>                 addCrossImportsSequence(schema, sequence);
>             }
>             // END QFS HACK
>         }
>     }
> {code}
> Benoit Lacelle
> ActivePivot Consultant @ Quartetfs

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to