You can define arrays for an element in a business object so that the element can contain more than one instance of data.
<xsd:element name="telephone" type="xsd:string" maxOccurs="3"/>This will create a list index for the element telephone that can hold up to three data instances. You may also use the value minOccurs if you are only planning to have one item in the array.
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="Customer"> <xsd:complexType> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="ArrayOfTelephone" type="ArrayOfTelephone"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name="ArrayOfTelephone"> <xsd:sequence maxOccurs="3"> <xsd:element name="telephone" type="xsd:string" nillable="true"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
The telephone element now appears as a child of the ArrayOfTelephone wrapper object.
<Customer> <name>Bob</name> <ArrayOfTelephone> <telephone>111-1111</telephone> <telephone xsi:nil="true"/> <telephone>333-3333</telephone> </ArrayOfTelephone> </Customer>In this case, the first and third items in the array index for the telephone element contain data, while the second item does not contain any data. If you had not used the nillable property for the telephone element, then you would have had to have the first two elements contain data.
DataObject customer = ... customer.setString("name", "Bob"); DataObject tele_array = customer.createDataObject("ArrayOfTelephone"); Sequence seq = tele_array.getSequence(); // The array is sequenced seq.add("telephone", "111-1111"); seq.add("telephone", null); seq.add("telephone", "333-3333");You can return the data for a given element array index by using code similar to the example below:
String tele3 = tele_array.get("telephone[3]"); // tele3 = "333-3333"In this example, a string named tele3 will return the data "333-3333".
You can fill the data items for the array in the list index by using fixed width or delimited data placed in a JMS or MQ message queue. You can also accomplish this task by using a flat text file that contains the properly formatted data