When given input like this:

   ...
   <xsd:complexType name="complexType2">
     <xsd:complexContent>
       <xsd:extension base="xsd:anyType">
    <xsd:choice>
       <xsd:element name="element" >
       </xsd:element>
    </xsd:choice>
       </xsd:extension>
     </xsd:complexContent>
   </xsd:complexType>
   ...

JaxMeXS generates an incorrect object structure.  It inserts the
representation of an extra <sequence> element above the representation
of the <choice> element, and leaves a null pointer in the particles
list.

More specifically, instead of:
- an XSGroup
   - with a 'choice' compositor
   - and a particles list
     - with one particle and
     - whose first particle represents the element,
there is:
- an XSGroup
   - with a 'sequence' compositor
   - and a particles list
     - whose length is 2,
     - whose first entry is null and
     - whose second entry is
       - an XSGroup
         - with a 'choice' compositor and
         - a particles list
           - with one particle and
           - whose first particle represents the element.

Attached is a program that demonstrates the problem.

This seems to apply to JaxMeXS in JaxMe 0.3.1, 0.4beta, and
the current default CVS branch (HEAD?).


Daniel



package test;

import org.apache.ws.jaxme.xs.*;
import org.apache.ws.jaxme.xs.parser.*;
import org.apache.ws.jaxme.xs.xml.*;
import org.xml.sax.*;
import javax.xml.parsers.ParserConfigurationException;


import java.io.*;

public class CheckBug_ExtraSequenceAndNullParticle
{



    public static void main( String[] args )
        throws Exception
    {
        System.err.println( "Checking bug: null particle in particles list"
                            + " and extra sequence group in hierarchy..." );
        String schemaContent =
            " "
            + "<xsd:schema "
            + "  xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; "
            + "  xmlns:xsdi=\"http://www.w3.org/2001/XMLSchema-instance\"; "
            + "  xsdi:schemaLocation=\"http://www.w3.org/2001/XMLSchema "
            + "  http://www.w3.org/2001/XMLSchema.xsd\"; "
            + "  > "
            + "  <xsd:complexType name=\"complexType1\"> "
            + "    <xsd:complexContent> "
            + "      <xsd:extension base=\"xsd:anyType\"> "
            + "        <xsd:choice> "
            + "           <xsd:element name=\"element\" >  "
            + "           </xsd:element> "
            + "        </xsd:choice> "
            + "      </xsd:extension> "
            + "    </xsd:complexContent> "
            + "  </xsd:complexType> "
            + "</xsd:schema> "
            ;

            InputSource source = 
                new InputSource( new ByteArrayInputStream( 
                                     schemaContent.getBytes( "ASCII" ) ) );
            source.setSystemId( "someScheme://x/whatever");

            XSParser parser = new XSParser();
            XSSchema schema = parser.parse( source );

            XSType type = schema.getTypes()[ 0 ];
            XSComplexType complexType = type.getComplexType();
            XSParticle typeParticle = complexType.getParticle();
            XSGroup shouldBeChoice = typeParticle.getGroup();

            XSParticle[] particles = shouldBeChoice.getParticles();

            /**
               Symptom:  Instead of an XSGroup with a 'choice' compositor
               and a particles list with one particle representing the
               element, there is an XSGroup with a 'sequence' compositor
               and a particles list whose length is 2, whose first 
               entry is null and whose second entry is an XSGroup with a
               'choice' compositor and a particles list with one particle 
               representing the element.
             */
            

            if ( shouldBeChoice.isSequence()
                && 2 == particles.length 
                && null == particles[ 0 ] 
                && null != particles[ 1 ] 
                && particles[ 1 ].isGroup()
                && particles[ 1 ].getGroup().isChoice()
                && 1 == particles[ 1 ].getGroup().getParticles().length
                && particles[ 1 ].getGroup().getParticles()[ 0 ].isElement()
                ) {
                System.err.println( "bug still exists" );
            }
            else  if ( shouldBeChoice.isChoice()
                 && 1 == particles.length
                 && null != particles[ 0 ] 
                 && particles[ 0 ].isElement() ) {
                System.err.println( "bug seems to be fixed" );
            }
            else {
                System.err.println( "bug has changed" );
            }
            
                
    } // main(...)


} // class CheckBug_ExtraSequenceAndNullParticle

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

Reply via email to