2. Add a Complex Child Element to a Return Type This page last changed on Nov 27, 2008. .stickable, h1, h2, h3, h4, h5 false true Show Sticky notes Hide Sticky notes Save Cancel Oracle Data Service Integrator Documentation > Data Services Developer's Guide # How To Add a Complex Child Element to a Return Type This topic describes how to add a complex child element to a return type, in Workshop for WebLogic or in the XML source of the return type. Add the Child Element Visually Edit the XML Source See Also ## Add the Child Element Visually Once you create a return type, you can add a complex type as a child of any element, in Query Map view. The complex child element must represent a physical data service. The parent element can have a one-to-many or one-to-one relationship with the child, depending on how you want the result data returned. ##### A Simple Return Type Before Adding a Child Element To add a complex child element to a return type visually: Open the logical data service in Workshop for WebLogic. Check Project Explorer. Be sure that your dataspace project has a physical data service for the complex child element you want to add. If it does not, add one File > New > Physical Data Service Click the Query Map tab. In the return type, right-click the new parent element, and choose Add Complex Child Element. For the Schema File field, browse (...) to the schema of the physical data service that represents the complex child element. For Type, choose a complex type from the schema, then click OK. From Project Explorer, drag the primary read function of the physical data service to the Query Map. Starting from the child element's For block, drag the zone icon to the child element in the return type. Starting from the child element's For block, drag the parent type of the complex element to the return type. This step maps all of the elements in the complex child to the return type. Right-click the title bar of the return type, and choose Save and Associate XML Type. Click the Overview tab, and expand the schema to view the complex child in the return type. You can also right-click the schema and choose Edit Schema to view the XML source. ## Edit the XML Source Adding the complex child element to the return type in the XML source accomplishes the same thing as adding it visually. To add a complex child element to a return type in XML source: Open the logical data service in Workshop for WebLogic. Check Project Explorer. Be sure that your dataspace project has a physical data service for the complex child element you want to add. If it does not, add it:
       File > New > Physical Data Service
4. Click the Overview tab. Right-click the return type schema in the center, and choose Edit Schema. You see the schema for the logical data service, without the child element:
       <?xml version="1.0" encoding="UTF-8"?>
       <xs:schema targetNamespace="ld:logical/MyCustomer" xmlns:xs="http://www.w3.org/2001/XMLSchema">
         <xs:element name="CUSTOMER">
           <xs:complexType>
             <xs:sequence>
               <xs:element name="CUSTOMER_ID" type="xs:string"/>
               <xs:element name="FIRST_NAME" type="xs:string"/>
               <xs:element name="LAST_NAME" type="xs:string"/>
               <xs:element name="CUSTOMER_SINCE" type="xs:date"/>
             </xs:sequence>
           </xs:complexType>
         </xs:element>
       </xs:schema>
6. In Project Explorer, right-click the schema file of the physical data service that represents the child element, and choose Open With. You see the schema of the child element. Copy the complex type from the physical data service schema to the logical data service schema. Take only the complex type:
       <xs:complexType>
                <xs:sequence>
                   <xs:element name="ADDR_ID" type="xs:string"/>
                   <xs:element name="CUSTOMER_ID" type="xs:string"/>
                   <xs:element name="FIRST_NAME" type="xs:string"/>
                   <xs:element name="LAST_NAME" type="xs:string"/>
                   <xs:element name="STREET_ADDRESS1" type="xs:string"/>
                   <xs:element name="STREET_ADDRESS2" type="xs:string" minOccurs="0"/>
                   <xs:element name="CITY" type="xs:string"/>
                   <xs:element name="STATE" type="xs:string"/>
                   <xs:element name="ZIPCODE" type="xs:string"/>
                   <xs:element name="COUNTRY" type="xs:string"/>
                   <xs:element name="DAY_PHONE" type="xs:string" minOccurs="0"/>
                   <xs:element name="EVE_PHONE" type="xs:string" minOccurs="0"/>
                   <xs:element name="ALIAS" type="xs:string" minOccurs="0"/>
                   <xs:element name="STATUS" type="xs:string" minOccurs="0"/>
                   <xs:element name="IS_DEFAULT" type="xs:short"/>
                </xs:sequence>
        </xs:complexType>
Right-click in the schema, and choose Validate. ## See Also ##### How Tos Create a Return Type Check Namespaces in Return Types ##### Other Resources XML Schema Tutorial (W3Schools) XML Schema Part 1: Structures (W3C) XML Schema Part 2: Datatypes (W3C)

Document generated by Confluence on Jan 13, 2009 15:57