try { dataSource.parse("XMLFileExample.xml"); } catch (Exception e) { e.printStackTrace(); }
<cplData xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/data.xsd"> <cplData> <classes> <class> <name>Alarm</name> <attribute> <name>ID</name> <javaClass>java.lang.String</javaClass> </attribute> <attribute> <name>severity</name> <javaClass>itest.table.datasourcexmltable.MainFrame$Severity</javaClass> <defaultValue>Warning</defaultValue> </attribute> <attribute> <name>acknowledged</name> <javaClass>java.lang.Boolean</javaClass> <defaultValue>false</defaultValue> </attribute> </class> </classes> <addObject id="alarm1" initializeDefaultValue="true"> <class>Alarm</class> <attribute name="ID">alarm1</attribute> </addObject> <addObject id="alarm2" initializeDefaultValue="false"> <class>Alarm</class> <attribute name="ID">alarm2</attribute> <attribute name="severity">Major</attribute> <attribute name="acknowledged">false</attribute> </addObject > <addObject id="alarm3" initializeDefaultValue="false"> <class>Alarm</class> <attribute name="ID">alarm3</attribute> <attribute name="severity">Major</attribute> <attribute name="acknowledged">true</attribute> </addObject > <addObject id="alarm4" initializeDefaultValue="false"> <class>Alarm</class> <attribute name="ID">alarm4</attribute> </addObject > <updateObject id="alarm2"> <attribute name="acknowledged">true</attribute> </updateObject> </cplData>
<classes>
XML element delimits the business model definition. This model
can also be defined in a separate file. For details, see Defining a dynamic class in XML.
"superClass"
) is resolved at the end of each
<classes>
element. As a consequence, you cannot define within the first
<classes>
element a class that inherits from a class defined within another
<classes>
element later in the file. For example, the following model
definition is incorrect:
<cplData xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/data.xsd"> <classes> <class> <name>Domain</name> <superClass>NetworkElement</superClass> </class> </classes> <classes> <class> <name>NetworkElement</name> <attribute> <name>name</name> <javaClass>java.lang.String</javaClass> </attribute> </class> </classes> </cplData>
<classes>
element as follows:
<cplData xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/data.xsd"> <classes> <class> <name>NetworkElement</name> <attribute> <name>name</name> <javaClass>java.lang.String</javaClass> </attribute> </class> <class> <name>Domain</name> <superClass>NetworkElement</superClass> </class> </classes> </cplData>
XML
Elements |
Attributes
|
Default
|
Description
|
---|---|---|---|
<cplData>
|
None |
Delimits
data definition. This element is required. The file
containing XML business data should necessarily start and end
with this element. |
|
<classes>
|
None |
Delimits the model definition, that is, dynamic class
definition. For details, see Defining a dynamic class in XML.
|
|
<class>
|
None |
Within an
<updateState>
element, defines the class of the added object.
|
|
<attribute>
|
Within an
<updateState>
or
<updateObject>
element, defines the values of the attributes.
|
||
name
|
This
attribute is mandatory. The name of the attribute as defined
in the object class. |
||
null
|
false
|
This attribute is optional. When
true
, it indicates that the value of the attribute is
null
.
|
|
javaClass
|
The attribute Java™ class as defined in the
IlpClass
|
This
attribute is optional. It specifies the Java class name of
the attribute value. It becomes mandatory if the attribute
value class is an abstract class. See Note 3. |
|
<updateState>
|
Within an
<updateObject>
element, defines incremental updates to attribute
objectState
for predefined business objects. See Defining states in XML.
|
||
<batch>
|
Group data source updates. This element may contain any
number of
<updateState>
,
<removeObject>
,
<updateObject>
. Also,
<batch>
elements can be nested.
|
||
<addObject>
|
Adds an object to the data source. This element contains a
mandatory
<class>
element. It may contain structural elements and
<attribute>
elements.
|
||
id
|
This
attribute is mandatory and should be unique. |
||
idClass
|
java.lang.String
|
This attribute is optional. It can be used to specify a Java
class name for the
id
. See Note 2.
|
|
initializeDefaultValue
|
true
|
This attribute is optional. When
true
, it initializes attributes to their default values.
|
|
container
|
This attribute is optional. It allows you to specify whether
the object is a container. An object is considered to be a
container if this attribute is set to
true
, if it contains
<children>
, or if another object is declared as its
<parent>
.
|
||
<updateObject>
|
Updates the value of an existing object. It may contain
structural elements,
<attribute>
and
<updateState>
elements.
|
||
id
|
This
attribute is mandatory. |
||
idClass
|
java.lang.String
|
This attribute is optional. It can be used to specify a Java
class name for the
id
. See Note 2.
|
|
container
|
This attribute is optional. It allows you to specify whether
the object is a container. An object is considered to be a
container if this attribute is set to
true
, if it contains
<children>
, or if another object is declared as its
<parent>
.
|
||
<removeObject>
|
Removes
an existing object. It should not contain any other data or
elements. |
||
id
|
This
attribute is mandatory. |
||
idClass
|
java.lang.String
|
This attribute is optional. It can be used to specify a Java
class name for the
id
. See Note 2.
|
|
childrenToo
|
true
|
This
attribute is optional. It specifies whether all the children
of the object should be removed from the data source. |
|
<children>
|
None |
Structural element indicating that an object is a potential
container, even if
<children>
does not contain any other subelements. This element can
contain
<child>
subelements.
|
|
<link>
|
Structural element that lets you specify the extremities of a
link. It contains one
<to>
and one
<from>
subelement.
|
||
idClass
|
java.lang.String
|
This attribute is optional. It can be used to specify a Java
class name for the
id
. See Note 2.
|
|
<parent>
See Note 1 |
Structural element. It contains the
id
of the parent object.
|
||
idClass
|
java.lang.String
|
This attribute is optional. It can be used to specify a Java
class name for the
id
. See Note 2.
|
|
<child>
See
Note 1
|
Contains
the ID of the child. |
||
idClass
|
java.lang.String
|
This attribute is optional. It can be used to specify a Java
class name for the
id
. See Note 2.
|
|
<to>
See
Note 1
|
Contains the
id
of the
to
extremity of a link.
|
||
idClass
|
java.lang.String
|
This attribute is optional. It can be used to specify a Java
class name for the
id
. See Note 2.
|
|
<from>
.
See
Note 1
|
Contains the
id
of the
from
extremity of a link.
|
||
idClass
|
java.lang.String
|
This attribute is optional. It can be used to specify a Java
class name for the
id
. See Note 2.
|
<parent>
,
<child>
,
<to>
, and
<from>
elements exists or not is not important. When the
corresponding object is created, either with the
<addObject>
XML element or through a call to a data source method, the
adapter that makes use of the structural information will
perform any necessary action to connect the representation
objects matching the business objects specified in the
structural element.
javaClass
attribute of the
<attribute>
element behaves like the
javaClass
attribute of the
<defaultValue>
element. See Attribute types.
<cplData>
,
<classes>
,
<class>
and
<attribute>
, which define the business model:
<cplData xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/data.xsd"> <classes> <class> <name>NetworkElement</name> <attribute> <name>name</name> <javaClass>java.lang.String</javaClass> </attribute> <attribute> <name>site</name> <javaClass>java.lang.String</javaClass> </attribute> <attribute> <name>position</name> <javaClass>ilog.cpl.graphic.IlpPoint</javaClass> </attribute> </class> <class> <name>Domain</name> <superClass>NetworkElement</superClass> </class> <class> <name>LinkElement</name> <attribute> <name>name</name> <javaClass>java.lang.String</javaClass> </attribute> </class> </classes> </cplData>
<addObject>
to create a new business object of the business class "
Domain
":
<addObject id="Domain1"> <class>Domain</class> <attribute name="name">Domain 1</attribute> <attribute name="site">Gentilly</attribute> <attribute name="position" javaClass="ilog.cpl.graphic.IlpPoint"> <x>100</x> <y>100</y> </attribute> </addObject>
<parent>
. The example creates a new business object
"Server1"
which is a child of business object
"Domain1"
.
<addObject id="Server1"> <class>Server</class> <parent>Domain1</parent> <attribute name="name">S1</attribute> <attribute name="site">Montreuil</attribute> <attribute name="position" javaClass="ilog.cpl.graphic.IlpPoint"> <x>100</x> <y>50</y> </attribute> </addObject>
<link
>,
<to>
and
<from>
. In this example, you create the link
"Link1"
which connects two objects
"Domain1"
and
"Domain2"
.
<addObject id="Link1"> <class>LinkElement</class> <attribute name="name">InterDomain</attribute> <link> <from>Domain1</from> <to>Domain2</to> </link> </addObject>
<updateObject>
. You can update simple attributes, such as
"name"
, and you can also change structural information such as
changing the end point of the link:
<updateObject id="Link1"> <attribute name="name">Server1-Domain2</attribute> <link> <from>Server1</from> <to>Domain2</to> </link> </updateObject>
<removeObject>
:
<removeObject id="Link1"/>