Business Objects and Data Sources > Groups > Loading a Group Defined in XML

This section shows how to load a group from an XML file into a data source. For detailed information about data sources, see section Data Sources.

All you have to do is create a data source using the data source default implementation defined by IltDefaultDataSource and pass the XML file to the parse method of the data source, as shown below.

dataSource = new IltDefaultDataSource();
dataSource.parse("GroupXMLFile.xml");

Below is an example of a group defined in XML format. For details about the XML elements used in this example, see Table 3.1, Elements in an XML Data File.

Depending on the group class, the shape of a group is defined either by IlpPolygon, IlpRect, or IlpPolyline. See Group Shapes for details.

How to Define a Group in XML
<cplData>
<addObject id="RectGroup">
  <class>ilog.tgo.model.IltRectGroup</class>
  <attribute name="name">RectGroup</attribute>
  <attribute name="position" javaClass="ilog.cpl.graphic.IlpRect">
     <x>100</x>  <y>200</y>   <width>100</width>  <height>50</height>
  </attribute>
  <attribute name="objectState" javaClass="ilog.tgo.model.IltOSIObjectState">
    <state>
      <administrative>Locked</administrative>
      <operational>Enabled</operational>
      <usage>Idle</usage>
    </state>
    <availability>PowerOff</availability>
    <control>ReservedForTest</control>
    <alarms>
      <new severity="Critical">5</new>
      <ack severity="Warning">12</ack>
    </alarms>
  </attribute>
</addObject>
<addObject id="PolyGroup">
  <class>ilog.tgo.model.IltPolyGroup</class>
  <attribute name="name">PolyGroup</attribute>
  <attribute name="position" javaClass="ilog.cpl.graphic.views.IlpPolygon">
    <point>  <x>50.0</x>    <y>20.0</y>   </point>
    <point>  <x>140.0</x>    <y>20.0</y>   </point>
    <point>  <x>140.0</x>    <y>100.0</y>   </point>
    <point>  <x>90.0</x>    <y>100.0</y>   </point>
    <point>  <x>90.0</x>    <y>140.0</y>   </point>
    <point>  <x>20.0</x>    <y>140.0</y>   </point>
    <point>  <x>20.0</x>    <y>90.0</y>   </point>
  </attribute>
  <attribute name="objectState"
           javaClass="ilog.tgo.model.IltBellcoreObjectState">
    <state>EnabledActive</state>
    <secState>TestFailure</secState>
    <procedural>Initializing</procedural>
    <misc>HighTemperatureWarning</misc>
    <performance state="Input">50</performance>
    <alarms>
      <new severity="Minor">3</new>
      <ack severity="Warning">4</ack>
    </alarms>
  </attribute>
</addObject>
<addObject id="LinearGroup">
  <class>ilog.tgo.model.IltLinearGroup</class>
  <attribute name="name">LinearGroup</attribute>
  <attribute name="position" javaClass="ilog.cpl.graphic.views.IlpPolyline">
    <point>  <x>350.0</x>    <y>100.0</y>   </point>
    <point>  <x>400.0</x>    <y>100.0</y>   </point>
    <point>  <x>420.0</x>    <y>50.0</y>   </point>
    <point>  <x>450.0</x>    <y>50.0</y>   </point>
   </attribute>
  <attribute name="objectState"
          javaClass="ilog.tgo.model.IltBellcoreObjectState">
    <state>EnabledIdle</state>
    <secState>Busy</secState>
    <procedural>Initializing</procedural>
    <misc>DoorAjar</misc>
    <alarms>
      <ack severity="Warning">2</ack>
    </alarms>
  </attribute>
</addObject>
</cplData>