Hi,

Here's my schema. I am able to compile this and this is perfectly alright.


?xml version="1.0" encoding="UTF-8" ?>
<xs:schema targetNamespace="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="BusRoute">
<xs:complexType>
  <xs:sequence>
    <xs:element name="Id" type="xs:string"/>

    <xs:element name="Bus">
        <xs:complexType>
            <xs:sequence>
                    <xs:element name="Id" type="xs:int"/>
                    <xs:element name="Type" type="xs:string"/>
                    <xs:element name="Model" type="xs:string"/>
               </xs:sequence>
               </xs:complexType>
    </xs:element>
           
    <xs:element name="Seat" maxOccurs="unbounded">
        <xs:complexType>
            <xs:sequence>
                           <xs:element name="Sn" type="xs:int"/>
                            <xs:element name="A" type="xs:string"/>
                            <xs:element name="Sx" type="xs:string"/>
                            <xs:element name="Q" type="xs:string"/>
                            <xs:element name="T" type="xs:string"/>
                            <xs:element name="Si" type="xs:string"/>
               
                    </xs:sequence>
                    </xs:complexType>
        </xs:element>


     </xs:sequence>
           </xs:complexType>
</xs:element>
       
</xs:schema>   

     
The problem I face with is the array elements returned from the API.  I worked with another one without array. did not have any problems at all.

BusRouteDocument brDoc = BusRouteDocument.Factory.parse(new StringReader(sb.toString()));
        BusRoute  busRoute = brDoc.getBusRoute();
       
//this is returning null.     
 System.out.println(busRoute.getBus());
       
            Seat[] seatArray = busRoute.getSeatArray();

//this is always zero.
            System.out.println(seatArray.length);
           
                    for(int j=0; j<seatArray.length; j++){
                       
                        System.out.print(seatArray[j].getSn());
                       
                    }
               
            }




This is the XML Message I am passing it to the API.

        sb.append("<?xml version='1.0' encoding='UTF-8'?>");
        sb.append("<BusRoute xmlns='http://www.w3.org/2001/XMLSchema'>");
        sb.append("<Id>B1001</Id>");
        sb.append("<bus><Id>1001</Id><Type>SS</Type><Model>1+1</Model></bus>");

        sb.append("<Seat>");
        sb.append("<Sn>1</Sn> <A>Y</A> <Sx>M</Sx> <Q>V</Q> <T>W</T> <Si>L</Si>");
        sb.append("</Seat>");
       
        sb.append("<Seat>");
        sb.append("<Sn>2</Sn> <A>Y</A> <Sx>M</Sx> <Q>V</Q> <T>W</T> <Si>L</Si>");
        sb.append("</Seat>");
       
        sb.append("</BusRoute>");


Thanks for your help.
Cheenu

Reply via email to