GXL Schemata
Now, as the graphs are constructed, which represent the GXL schemata (shown as class diagrams), in the last section, it is possible to create the appropriate GXL code for those graphs. Those two transformations, on the one hand building the schema graph out of a given UML class diagram, as it has been done in the last paragraph and on the other hand creating the GXL code for this schema graph, which is shown in this paragraph, will be done by XIG in the future.
Note: The arrows below are links to the corresponding steps in gxl/from_graph_to_schema.
step 1: The Prolog and the Root
Element
|
representing UML object diagram |
GXL code (xml file) |
|
no diagram |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE gxl SYSTEM "gxl.dtd">
<gxl xmlns:xlink="www.w3.org/1999/xlink"/> |
The first step was the identification of the file as an xml document and the link to the extern GXL DTD (see step1 in gxl/gxl-graphs here). There are no changes needed here.
|
representing UML object diagram |
GXL code (xml file) |
|
|
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE gxl SYSTEM "gxl.dtd">
<gxl> <graph id="g1"> <type xlink:href="MetaSchema#GraphClass"/>
<node id="n1"> <type xlink:href="MetaSchema#GraphClass"/> <attr name="name"> <string>graph1</string> </attr> </node>
<node id="n2"> <type xlink:href="MetaSchema#GraphClass"/> <attr name="name"> <string>graph2</string> </attr> </node><node id="n3"> <type xlink:href="MetaSchema#GraphClass"/> <attr name="name"> <string>graph3</string> </attr> </node> </graph> </gxl> |
In step two, one graph has to be defined again, containing three nodes (those are instances of GraphClass). Every node object is carrying an attribute, named name, containing the name of the represented graph.
|
representing UML object diagram |
GXL code (xml file) |
|
|
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE gxl SYSTEM "gxl.dtd">
<gxl> <graph id="g1"> <type xlink:href="MetaSchema#GraphClass"/
<node id="n1"> <type xlink:href="MetaSchema#GraphClass"/> <attr name="name"> <string/> </attr> </node><node id="n2"> <type xlink:href="MetaSchema#NodeClass"/> <attr name="name"> <string>node_class1</string> </attr> </node> <node id="n3"> <type xlink:href="MetaSchema#NodeClass"/> <attr name="name"> <string>node_class2</string> </attr> </node> <edge from="n1" to="n2"> <type xlink:href="MetaSchema#contains"/> </edge> <edge from="n1" to="n3"> <type xlink:href="MetaSchema#contains"/> </edge> </graph> </gxl> |
This time, there are three node objects again, but only one instance of GraphClass, the other two are derived from NodeClass. As it can be seen, every node object has a string attribute with the name of the represented UML element. Following the rules of the GXL Meta Schema, two edges have to be paste in, both starting at the GraphClass instance and pointing at the NodeClass instances.
|
representing UML object diagram |
GXL code (xml file) |
|
|
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE gxl SYSTEM "gxl.dtd">
<gxl> <graph id="g1"> <type xlink:href="MetaSchema#GraphClass"/><node id="n1"> <type xlink:href="MetaSchema#GraphClass"/> <attr name="name"> <string/> </attr> </node><node id="n2"> <type xlink:href="MetaSchema#NodeClass"/> <attr name="name"> <string>node_class1</string> </attr> </node> ... <!-- one node-node is left out here --> <node id="n4"> <type xlink:href="MetaSchema#NodeClass"/> <attr name="name"> <string>node_class3</string> </attr> </node><node id="n5"> <type xlink:href="MetaSchema#AttributeClass"/> <attr name="name"> <string>bool_attr</string> </attr> </node> ... <!-- eight attribute-nodes are left out here --> <node id="n14"> <type xlink:href="MetaSchema#AttributeClass"/> <attr name="name"> <string>set_attr</string> </attr> </node><node id="n15"> <type xlink:href="MetaSchema#BoolVal"/> </node> ... <!-- twelve value-nodes are left out here --> <node id="n28"> <type xlink:href="MetaSchema#BoolVal"/> </node><edge from="n1" to="n2"> <type xlink:href="MetaSchema#contains"/> </edge>... <!-- one contains-edge is left out here --> <edge from="n1" to="n4"> <type xlink:href="MetaSchema#contains"/> </edge><edge from="n2" to="n5"> <type xlink:href="MetaSchema#hasAttribute"/> </edge> ... <!-- eight hasAttribute-edges are left out here --> <edge from="n4" to="n14"> <type xlink:href="MetaSchema#hasAttribute"/> </edge><edge from="n5" to="n15"> <type xlink:href="MetaSchema#hasDefaultValue"/> </edge> ... <!-- eight hasDefaultValue-edges are left out here --> <edge from="n14" to="n24"> <type xlink:href="MetaSchema#hasDefaultValue"/> </edge><!-- the composite-associations are left out --> </graph> </gxl> |
To get a better overview of the shown graph, the explanations start in the upper left corner, where the node object, representing the graph, can be seen. The next column is built by the three objects, typed NodeClass, representing the nodes of the schema. The attributes of those node objects are represented by node objects which reference AttributeClass, and form the next column. And last, there are objects for the representation of the types of contained values on the right side of the picture.
The next step are the connections of the nodes, started on the lefthand side again. At first three links are needed (typed contains) for modelling the content association between the graph object and the node objects. As second directed links are needed (typed hasAttribute), which connect the contained attribute nodes to their node objects. Selfevident the attributes have values, which are represented by the nodes on the righthand side (they are linked to the attribute nodes by using an edge typed hasDefaultValue).
Note: it is not clear yet, how the composite associations from the composite type objects to the atomic type objects should be instantiated here, therefore they are left out (as many similar elements)
|
representing UML object diagram |
GXL code (xml file) |
|
|
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE gxl SYSTEM "gxl.dtd"> <gxl> <graph id="g1"> <type xlink:href="MetaSchema#GraphClass"/><node id="n1"> <type xlink:href="MetaSchema#GraphClass"/> <attr name="name"> <string/> </attr> </node> <node id="n2"> <type xlink:href="MetaSchema#NodeClass"/> <attr name="name"> <string>node_class1</string> </attr> </node> ... <!-- all following node-nodes are left out here --> <node id="e1"> <type xlink:href="MetaSchema#EdgeClass"/> <attr name="name"> <string/> </attr> <attr name="isDirected"> <bool>false</bool> </attr> </node> ... <!-- all following edge-nodes are left out here -->
<node id="a1"> <type xlink:href="MetaSchema#AttributeClass"/> <attr name="name"> <string>edgemode</string> </attr> </node>... <!-- all following attribute-nodes are left out here --> <node id="v1"> <type xlink:href="MetaSchema#StringVal"/> </node> ... <!-- all following value-nodes are left out here --> <edge from="e1" to="n2"> <type xlink:href="MetaSchema#from"/> </edge> <edge from="e1" to="n3"> <type xlink:href="MetaSchema#to"/> </edge> ... <!-- all following from- and to-edges are left out here -->
<edge from="n1" to="a1"> <type xlink:href="MetaSchema#hasAttribute"/> </edge>... <!-- all following hasAttribute-edges are left out here --> <edge from="a1" to="v1"> <type xlink:href="MetaSchema#hasDefaultValue"/> </edge> ... <!-- all following hasDefaultValue-edges are left out here -->
<edge from="n1" to="n2"> <type xlink:href="MetaSchema#contains"/> </edge>... <!-- all following contains-edges are left out here --> </graph> </gxl> |
As in the former graph this picture contains one graph object and some node objects again, linked by contains type edge objects.But in addition to that, three more EdgeClass derived objects can be recognized, which are therefore edge objects. These are concatenated with the graph object by contains edges again (they are specialized GraphElementClasses, too). As in the upper example, there are also attributes here - three attribute objects, two associated with the containing element in form of the object, typed GraphClass, another one, which is linked to the object, typed EdgeClass, by the hasAttribute typed edge again. The connections between the attribute objects and the value objects are given by hasDefaultValue typed edges.
step 6: Ordering of Incidences
|
representing UML object diagram |
GXL code (xml file) |
|
|
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE gxl SYSTEM "gxl.dtd"> <gxl> <graph id="g1"> <type xlink:href="MetaSchema#GraphClass"/><node id="n1"> <type xlink:href="MetaSchema#GraphClass"/> <attr name="name"> <string/> </attr> </node>
<node id="n2"> <type xlink:href="MetaSchema#NodeClass"/> <attr name="name"> <string>node_class1</string> </attr> </node>... <!-- all following node-nodes are left out here --> <node id="e1"> <type xlink:href="MetaSchema#EdgeClass"/> <attr name="name"> <string>edge_class1</string> </attr> <attr name="isDirected"> <bool>true</bool> </attr> </node> ... <!-- all following edge-nodes are left out here -->
<node id="a1"> <type xlink:href="MetaSchema#AttributeClass"/> <attr name="name"> <string>bool_attr</string> </attr> </node> <node id="v1"> <type xlink:href="MetaSchema#BoolVal"/> </node>
<edge from="e1" to="n2"> <type xlink:href="MetaSchema#from"/> <attr name="isOrdered"> <bool>true</bool> </attr> </edge> <edge from="e1" to="n2"> <type xlink:href="MetaSchema#to"/> <attr name="isOrdered"> <bool>true</bool></attr> </edge>... <!-- all following from- and to-edges are left out here --> <edge from="e2" to="a1"> <type xlink:href="MetaSchema#hasAttribute"/> </edge> <edge from="a1" to="v1"> <type xlink:href="MetaSchema#hasDefaultValue"/> </edge> <edge from="n1" to="n2"> <type xlink:href="MetaSchema#contains"/> </edge> ... <!-- all following contains-edges are left out here --> </graph> </gxl> |
From now the graph object, its connections and the constructs, defined by the attribute model, will not be mentioned anymore, because there will be no more improvements there.
This time there are two node objects again, which are connected with themselves and each other by edges. These edges are defined by node objects, typed EdgeClass. The from and to links are visualized as nodes in the upper graph, using the stereotype edge and carrying the attribute isOrdered (for marking the edge end as ordered); they are realized as normal edges with contained attributes in the GXL code (see right column).
|
representing UML object diagram |
GXL code (xml file) |
|
|
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE gxl SYSTEM "gxl.dtd"> <gxl> <graph id="g1"><type xlink:href="MetaSchema#GraphClass"/> <node id="n1"> <type xlink:href="MetaSchema#GraphClass"/> <attr name="name"> <string>graph_class1</string> </attr> </node> <node id="n2"> <type xlink:href="MetaSchema#NodeClass"/> <attr name="name"> <string>node_class1</string> </attr> </node>... <!-- all following node-nodes are left out here --> <node id="r1"> <type xlink:href="MetaSchema#RelationClass"/> <attr name="name"> <string>relation_class</string> </attr> </node> <node id="re1"> <type xlink:href="MetaSchema#RelationEndClass"/> <attr name="directedTo"> <string>relation</string> </attr> <attr name="isOrderedRelation"> <bool>false</bool> </attr> </node>... <!-- all following relationend-nodes are left out here --> <node id="a1"> <type xlink:href="MetaSchema#AttributeClass"/> <attr name="name"> <string>edgeids</string> </attr> </node> ... <!-- all following attribute-nodes are left out here --> <node id="v1"> <type xlink:href="MetaSchema#BoolVal"/> </node>... <!-- all following value-nodes are left out here --> <edge from="r1" to="re1"> <type xlink:href="MetaSchema#hasRelationEnd"/> </edge> ... <!-- all following hasRelationEnd-edges are left out here --> <edge from="re1" to="n2"> <type xlink:href="MetaSchema#relatesTo"/> <attr name="role"> <string>from_node1_class</string> </attr> </edge>... <!-- all following relatesTo-edges are left out here --> <edge from="n1" to="a1"> <type xlink:href="MetaSchema#hasAttribute"/> </edge> ... <!-- all following hasAttribute-edges are left out here --> <edge from="a1" to="v1"> <type xlink:href="MetaSchema#hasDefaultValue"/> </edge>... <!-- all following hasDefaultValue-edges are left out here --> <edge from="n1" to="n2"> <type xlink:href="MetaSchema#contains"/> </edge>... <!-- all following contains-edges are left out here --> </graph> </gxl> |
The interesting aspect in this example is the transformation of the relation. The first step is an object, typed RelationClass, which is the actual relation, storing the name as a string attribute. The second step are nodes, typed RelationEndClass - the schema elements for the tentacles of the relation, which contain the information about the target node type and wether it is ordered at the relation node, or not. And last step are, at the one hand the hasRelationEnd typed edges, which connect the relation object and the relationend objects. At the other hand, there are the relatesTo typed edges, which are the link between these relationend objects and the node objects. They contain the role of the tentacle as a string attribute and the bool attribute isOrdered, which shows the ordering status at the pointed element.
|
representing UML object diagram |
GXL code |
|
no diagram |
The GXL code of hierarchical graphs will follow in this step. Due to the ongoing discussion about their implementation in GXL it is not possible at the moment to show it here.