• Keine Ergebnisse gefunden

GXL Schema API

N/A
N/A
Protected

Academic year: 2022

Aktie "GXL Schema API"

Copied!
20
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

University of Koblenz-Landau

Institute for Software Technology Prof. Dr. Jürgen Ebert

GXL Schema API

28th January 2004

Kevin Hirschmann Volker Riediger Andreas Winter

Project Report 1/2004

(2)

Abstract

The GXL Schema API represents the part of the GXL API concerned with graph schemas. These schemas describe the structure of their instance graphs. This paper gives a general overview about schemas in GXL and describes how to use the GXL Schema API by an example.

Third party components

GXLValidator contains the following components provided by third parties:

Xerces-C++ 1.7.0 XML Parser

This product includes software developed by the Apache Software Foundation.

http://www.apache.org/

STLPort 4.5.3 C++ Template Library http://www.stlport.org

(3)

Contents

1 Introduction 4

2 GXL Instance Graphs 5

3 GXL Schema 8

3.1 Graph part . . . 9 3.2 Domain Part . . . 9 3.3 Value Part . . . 10

4 GXL Schema API 10

4.1 GXL Schema API: General Usage . . . 10 4.2 Example: A Schema for JAVA . . . 11

5 Conclusion: Tools and further development 16

(4)

4 Introduction

1 Introduction

GXL (Graph eXchange Language) [5] is a standarized language for exchanging graph-based in- formation. GXL 1.0 was finally released on Feb. 14, 2001 during the ”Dagstuhl Seminar on Interoperability of Reengineering Tools” in Saarland, Germany. Later on graph- and reverse engineering related conferences were used for further discussions and experience reports. Mean- while, GXL is beeing used by over 30 researchers in eight countries. The goal of GXL is to enable interoperability between tools that use graphs as data stores. Beeing a sublanguage of XML (eXtensible Markup Language) [7], the GXL syntax is given by a DTD (Document Type Definition). GXL is designed to store typed, attributed, directed, ordered graphs (so called:

TGraphs), hypergraphs and hierarchical graphs. This diversity of graph types ensures that GXL can be used to exchange a wide variety of graph classes.

This paper describes the GXL Schema API. It is the top level of a multi layered architecture for creating and accessing GXL schema graphs. A document containing a schema graph is written in XML. A XML document can be accessed and processed by DOM (Document object model) [6]. The GXLAPI uses a the XERCES [1] as implementation of the DOM interface. The GXL Instance API [9] wraps the DOM interface and is again wrapped by the GXL Schema API (see fig. 1). This is possible because a GXL schema is a GXL instance itself.

GXL Schema API GXL Instance API

DOM API XML Standards

XERCES C++

(XML API)

Figure 1: Layering of the GXL Schema API architecure

The GXL Schema API simplifies the development of new tools in the GXL. These tools usually are converters from a proprietary format to GXL or vice versa. This paper gives a brief introduc- tion into GXL, describes general constraints on using the GXL Schema API, and describes the usage by an example.

(5)

GXL Instance Graphs 5

2 GXL Instance Graphs

This chapter explains how graphs can be exchanged with the help of GXL. The following de- scription of GXL graphs applies not only to GXL instance graphs, but also to graph schemas, which are instance graphs of a metaschema.

The GXL Graph Model defines GXL graphs that can be exchanged with GXL. GXL documents can contain an arbitrary number of graphs. As you can see from the figure, GXL graphs are composed of graph elements. Those are nodes, edges and relations.

contains contains 0..n 0..n

1 contains 0..1

refersDocument

refersType hasType

0..n 1

0..n 0..1

0..1 0..n

0..1

hasAttribute

0..n 0..n

Attribute name kind AttributedElement

id

TypedElement Type

GXL Graph

roleedgeids hypergraph edgemode

GraphElement

LocalConnection isdirected

Node Relation Edge

to

relatesTo ordered from

Relend role direction startorder endorder

0..n 0..n

0..n

1

1

1 to

from relatesTo

GXL Graph Model Version 1b (graph part) 30.01.2003 (OH)

0..n

Figure 2: GXL Graph Model (graph part)

Graphs can posess a type and an arbitrary number of attributes. The same applies to graph elements. Attributes contain exactly one value. A value (see figure 3 ) can be of one of five atomic domains (bool, float, int, string and enum), an URI (Unified Resource Identifier) or of one of four composite domains (bag, set, seq, tup). Relations can exist among an arbitrary number of graph elements. Exactly one relation end (relend) corresponds to each graph element,

(6)

6 GXL Instance Graphs

participating in a relation. Edges are binary relations, i.e. they exist between two graph elements.

RelatesTo-incidence of relends is a generalization of from- and to-incidences of edges.

hasComponentValue {ordered}

hasValue Attribute

name kind

LocatorVal uri: string

GXL Graph Model Version 1b (value part) 30.01.2003 (OH) Value

CompositeVal AtomicVal

value: string

BoolVal FloatVal IntVal StringVal EnumVal BagVal SetVal SeqVal TupVal

0..n 0..n

0..n 1

Figure 3: GXL Graph Model (value part)

Let us consider one example of a GXL graph. An UML object diagram of this sample graph is shown on the figure 4. This graph contains four typed attributed nodes and three typed at- tributed edges. Types of the nodes and edges correspond to a graph-schema. This simple graph is represented in GXL in quite an intuitive and easy way (see figure 5).

line = 127

r1: ref

file = "main.c"

p: Proc

file = "test.c"

q: Proc

line = 27

r2: ref

line = 42

c: call

line = 225

v: Var

line = 316

w: Var

Figure 4: a simple graph

We can describe a sample structure of a GXL document on this example. GXL documents, like any XML documents, start with a specification of an XML version and a type of document, referring to a corresponding DTD. All tags of GXL documents are placed between<gxl>start and end tags. The document can contain an arbitrary number of graphs, each of them has a unique identifier. Each graph element belongs to a type, specified in the type element by the reference to a schema graph. Inside the corresponding graph tags there are descriptions of graph elements that compose the graph. Those are node, edge or rel tags which describe corresponding

(7)

GXL Instance Graphs 7

<?xmlversion = "1.0"?>

<!DOCTYPEgxl SYSTEM "http://www.gupro.de/GXL/gxl-1.0.dtd">

<gxl>

<graphid = "simpleExample"

edgeids = "true">

<typexlink:href = "schema.gxl"/>

<nodeid = "p">

<typexlink:href =

"schema.gxl#Proc"/>

<attrname = "file">

<string>main.c</string>

</attr>

</node>

<nodeid = "q">

<typexlink:href =

"schema.gxl#Proc"/>

<attrname = "file">

<string>test.c</string>

</attr>

</node>

<nodeid = "v">

<typexlink:href =

"schema.gxl#Var"/>

<attrname = "line">

<string>225</string>

</attr>

</node>

<nodeid = "w">

<typexlink:href =

"schema.gxl#Var"/>

<attrname = "line">

<string>316</string>

</attr>

</node>

<edgeid = "r1"

from = "p" to = "v"/>

<typexlink:href =

"schema.gxl#ref"/>

<attrname = "line">

<int>127</int>

</attr>

</edge>

<edgeid = "r2"

from = "q" to = "w"/>

<typexlink:href =

"schema.gxl#ref"/>

<attrname = "line">

<int>27</int>

</attr>

</edge>

<edgeid = "c"

from = "p" to = "q"/>

<typexlink:href =

"schema.gxl#call"/>

<attrname = "line">

<int>42</int>

</attr>

</edge>

</graph>

</gxl>

Figure 5: a simple graph in GXL

graph elements. Graph elements have unique identifiers and can contain an arbitrary number of attributes, each having a single value of a certain domain.

(8)

8 GXL Schema

3 GXL Schema

One important feature of GXL is the capability to define and exchange graph schemas. A graph in general is only a structure of nodes and edges. The context in which a graph is used defines its types of nodes and edges, their ordering and the relations between the graph elements.

The context of a graph is described by a graph schema. In GXL, the graph schema itself is a graph. The class of schema graphs again is defined by the GXL-metaschema which is an instance of itself. Since a graph schema is a graph, it can be represented by GXL and be treated like any instance graph (It is an instance of the metaschema). As described by the metamodel (figures 6, 7, 8) a graph schema comprises graph, node, edge, relation and relationend classes. These may be related to attribute classes by „hasAttribute“-edges to indicate that instances of these classes carry certain attributes. Attribute classes again are related to a domain. Within graph schemas GXL supports the usage of standard modeling-features like inheritance and abstract classes.[8]

A graph schema can be divided into three major parts:

1. The graph part including GraphClasses, GraphElementClasses and their AttributeClasses 2. The domain part including AtomicDomains, CompositeDomains and LocatorDomain 3. The value part including AtomicVal, LocatorVal and CompositeVal

contains 0..1 0..n

1 0..n

hasAttribute

0..n 0..n

0..n 0..n

0..n

1

1

1 to

from relatesTo

GXL Metaschema Version 1b (graph part) 30.01.2003 (OH) AttributeClass

name: string AttributedElementClass

GraphClass name: string

relatesTo limits: int x int isordered: bool AggregationClass

aggregate: (from, to)

CompositionClass hasRelationEnd

1 0..n hasAsComponentGraph role: string

limits: int x int isordered: bool

GraphElementClass name: string isabstract: bool

isA 0..n 0..n

GraphClass GXL composes all concepts

<<GraphClass>>

GXL

upper bounds defining infinity ("*"

in UML, "n" in Rose) are encoded by "-1" (cf. XMI) RelationClass NodeClass EdgeClass

isdirected: bool

RelationEndClass

directedto: (relation, target, undirected) role: string

from limits: int x int isordered: bool

to limits: int x int isordered: bool

Figure 6: GXL-metaschema: graph part

(9)

3.1 Graph part 9

3.1 Graph part

A graph schema contains one or more graph classes. Some of these are on top level, other graph classes may be embedded in graph element classes and describe subgraphs of a hierarchical graph. A graph class is adjacent to all of its graph elements, can be identified by its unique name and may be connected to multiple attribute classes by „hasAttribute“-edges.

A graph class contains node classes, edge classes and relation classes which may again be con- nected to attribute classes. All of these graph element classes may inherit from other graph element classes of the same kind (e.g. a node class from an other node class, an edge class from an other edge class). Graph element classes may be marked as abstract.

An edge class connects two, not necessary different, graph elements. The from-edge indicates the graph element class from which the edge class comes from and the to-edge indicates to which graph element class it goes. The to/from edges carry attributes about their cardinalities and if they are ordered or not. Although an edge class has always a to- and a from-edge, it can be marked as undirected to ignore its direction.

EdgeClass is subclassed by AggregationClass, which represents a „is part of“-relationship. Since an edge class may be undirected it is necessary to indicate the aggregate by setting the „aggregate“- attribute appropriately. Aggregation class again is subclassed by CompositionClass. A compo- sition class has the additional semantic that the members of the aggregate cannot exist without it.

In contrast to edge classes, a relation class connect to more than two graph element classes. This is represented by relation end classes. Relation end classes may be directed.

3.2 Domain Part

Graph classes, graph element classes, and relation end classes may related to attribute classes by hasAttributeClass-edges. Attribute classes may even be related to other attribute classes.

An attribute class is always connected to exactly one domain. The domain defines valid values for instances. On the XML level values are either XML elements (composite values) or strings (atomic values and locator). GXL defines several domains to describe which strings or elements are valid in the current context. There are three types of domains:

1. AtomicDomain, which comprises Bool, Int, String, Enum andFloat domains.

These define, that the associated attribute(s) have exactly one value.

2. CompositeDomainis superclass ofSet,Seq,Bag, Tup. The first three have exactly one component domain which specifies the domain of the included elements. A tuple domain has an ordered sequence of component domains so that a tuple value is composed of multiple values.

3. LocatorDomaindefines values that are pointers to other documents.

(10)

10 GXL Schema API

hasComponent {ordered}

GXL Metaschema Version 1b (attribute part) 30.01.2003 (OH)

0..n 1..n

Bool Float Int String Bag Set Seq Tup

CompositeDomain AtomicDomain

Locator Enum

Domain

Value AttributeClass

name: string

hasDomain hasDafaultValue

0..n 0..1

0..n

Value structure 0..1 matches domain specification

Bag, Set and Seq have exactly one domain component 0..n

1..n

contains Value

EnumVal value: string

Figure 7: GXL-metaschema: domain part

3.3 Value Part

Attribute classes may have a default value. In GXL Schema, a default value is not merely a string, but a node containing either an attribute carrying a string or beeing connected to one or more other values in case of composite domains.

This indicates the attribute carries this value, if no other is assigned. The hierarchy of default values is similiar to the domain structure.

1. Atomic values, which compriseBool, Int, String, EnumandFloatvalues carry a string attribute textttvalue.

2. Composite values contain multiple values of the appropriate domain.

3. Locator values own one attribute which contains an URI.

4 GXL Schema API

4.1 GXL Schema API: General Usage

The GXL Schema API has been developed to allow easy access to and creation of a GXL schema.

It has been implemented in C++ and is portable to WindowsTMand LinuxTM. Internally, it uses a GXL graph for representing the schema.

(11)

4.2 Example: A Schema for JAVA 11

hasComponentValue {ordered}

LocatorVal uri: string GXL Metaschema

Version 1b (value part) 30.01.2003 (OH)

Value

CompositeVal AtomicVal

value: string

BoolVal FloatVal IntVal StringVal EnumVal BagVal SetVal SeqVal TupVal

0..n 0..n

Figure 8: Metaschema: value part

When creating a schema, several constraints have to be met. The GXL Schema API throws ex- ceptions (e.g. GXLDuplicateAttributeClassException) to show that a constraint has been broken and it is up to the API user to deal with this exception. Since the API design doesn’t allow to remove elements, you might not always be able to recover from a constraint violation.

When calling a constructor for an atomic domain or an atomic default value the API checks if the domain or default value already exists. Is this the case no new element in the schema graph will be created. Instead the old one will be reused.

All classes of the GXL Schema API are prefixed by GXL to avoid name clashes. An overview and complete documentation is available as doxygen[2] comments , where all interfaces are described. The following example uses only a small subset of the available features.

4.2 Example: A Schema for JAVA

The usage of the API will be explained by how you could create a schema to describe a subset of the programming language JAVA. For example you would use a JAVA schema to represent JAVA source files. First you would like to define which elements might occur in such a source file. The following sections provide a step by step description for creating the GXL schema for the UML class diagram depicted in fig. 9.

When you have a UML class diagram like figure 9 and you would like to transfer it into a GXL Schema representation, you have to know which GXL schema element is related to each UML element. GXL supports a subset of UML features. A graph class is equivalent to a class diagram. Classes are modeled as GXL node classes. Relationships between GXL node classes are modeled as GXL edge classes (for binary relationships) or as GXL relation classes (for n- ary relationships). The attributes of the graph element classes (node-, edge-, relation, graph-, and relationend classes) are modeled as attribute classes. The domains of attribute classes are represented by a instance of a concrete subclass of GXLDomain. Aggregation and composition are modeled by aggregation- and composition class. Inheritance is represented by an „isA“-edge.

(12)

12 GXL Schema API

isSubPackageOf

isClassOfPackage

isAttributeOf Class

1..1

0..*

0..1 0..*

0..* 1 1,1 0..*

JavaNamedElement name: String

JavaPackage

JavaAttribute

JavaClass

AccModElement accessModifier : AccessModDomain AccessModDomain<<enumeration>>

private empty protected public

isMethodOfClass JavaMethod

Figure 9: UML representation: partial JAVA schema First steps

Here comes a step by step description of how to use the GXL Schema API to write a program for the JAVA example. Each step consists of two parts. The first explains why things are to be done. The second part shows the lines of code to achieve the objectives.

The GXL Schema API as well as the GXL Instance-API use the validating XML parser ”XERCES”, under developement of the apache software foundation. That’s why the first thing to be done is to initialize theXMLPlatformUtils.

XMLPlatformUtils::Initialize();

A schema is treated like any GXL graph. Hence, it is encapsulated in an object of the class GXLDocument. For our schema an empty document has to be created.

GXLDocument doc = GXLDocument::createDocument();

GXLAPI uses a DOM-Tree as data structure for the XML document. New objects are created by constructor calls. The first parameter of such a call is usually the parent element in the DOM- Tree to which the new element is appended. Since we want to create a new schema, we need a pointer to its parent element, which is a GXLGxl object.

(13)

4.2 Example: A Schema for JAVA 13

GXLGxl gxl = doc.getGXL();

Now we create a new, emptyGXL Schemawith the name"partialJAVAschema". From this empty schema we start to build our JAVA-schema.

GXLSchema schema(gxl, "partialJAVAschema");

UML Class Diagram -> GXL graph class

A GraphClass describes the structure and elements of one kind of graphs. In this case we want to describe the structure of a part of the language JAVA.

GXLGraphClass gc(schema, "JAVAGraphClass");

UML Classes -> GXL node classes with attributes

In our schema we want to model packages, classes, attributes and methods as NodeClasses.

GXLNodeClass javaPackage(gc, "JavaPackage");

GXLNodeClass javaClass(gc, "JavaClass");

GXLNodeClass javaAttribute(gc, "JavaAttribute");

GXLNodeClass javaMethod(gc, "JavaMethod");

Packages, classes, attributes and methods are identified by their name. To avoid that we will have to add a name to each of theNodeClassesan AttributeClass„name“ we inherit from the superclassJavaNamedElement. This class is marked as abstract, since there exists no equivalent JAVA element.

GXLNodeClass javaNamedElement(gc, "JavaNamedElement",

"JavaNamedElement", GXLSchemaConst::abstract);

javaPackage.setIsA(JavaNamedElement);

javaClass.setIsA(JavaNamedElement);

javaMethod.setIsA(JavaNamedElement);

javaAttribute.setIsA(JavaNamedElement);

Now we have to add a attribute class „name“ to the class JavaNamedAttribute. Before we can create a new attribute class we have to create its domain. The attribute name of package, classandmethodwill have the domainString. It is added to a schema.

GXLStringDomain stringDomain(schema);

Now we create a new attribute class which is added toJavaNamedElement. It has the domain

„stringDomain“ and the name „name“. It might be possible (for example if you load an already existing gxldocument) that the names you give the attributes already exist. An exception is thrown in this case, since it is forbidden to add multiple attributes with the same name to the same graph element.

(14)

14 GXL Schema API

try{

GXLAttributeClass namedAttr(schema, "name", stringDomain);

javaNamedElement.addAttributeClass(namedAttr);

}

catch(GXLDuplicateAttributeClassException& e){

RGINFO(GXLUtil::transcode(e.msg()));

}

Creating an Attribute with Enumeration Domain

Classes, methods and attributes have access modifiers. We introduce an abstract GXLNodeClass

„accModElement“. Later we will add an GXLAttributeClass for the modifier.

GXLNodeClass accModElement(gc, "accModElement",

"accModElement", GXLSchemaConst::abstract);

javaClass.setIsA(accModElement);

javaMethod.setIsA(accModElement);

javaAttribute.setIsA(accModElement);

JAVA supports four different access modifiers. To add an attribute to each method an appropriate domain is needed. In this case we use an enumeration. First we have to define of which values the enumeration consists.

GXLEnumDomainVal pubMod(schema, "publicModifier", "public");

GXLEnumDomainVal protMod(schema, "protectedModifier", "protected");

GXLEnumDomainVal privMod(schema, "privateModifier", "private");

GXLEnumDomainVal emptyMod(schema, "emptyModifier", "empty");

The domain of access modifiers is an enumeration. This domain has to be created with the first contained value. Afterwards, additional values are added.

GXLEnumDomain accessModDomain(schema, "accessModDom", pubMod);

accessModDomain.addValue(protMod);

accessModDomain.addValue(privMod);

accessModDomain.addValue(emptyMod);

Now we can create an attribute class, which represents the access modifier and attach this to the abstractaccModElement.

try{

GXLAttributeClass accModAttr = GXLAttributeClass(schema, "accessModifier", accessModDomain, "accessModifierID");

accModElement.addAttributeClass(labelAttr);

}

catch(GXLDuplicateAttributeClassException& e){

RGINFO(GXLUtil::transcode(e.msg()));

}

(15)

4.2 Example: A Schema for JAVA 15

Modeling Relationships

For modeling the associatons between the UML classes we use GXL edge classes. Before cre- ating an association, we have to consider the multiplicities. A package can be part of another package, but not more than one. Besides other packages, a package contains an arbitrary number of classes. A class is always a member of exactly one package. A method can be a member of a class (but it can also be a member of an interface). A GXLFrom/GXLToobject represents a container for the cardinality constraints and ordering. A cardinality of “-1„ represents infinite.

The from/to edges are created by calling theGXLEdgeClassconstructor. They are not created by theGXLFrom/GXLToconstructor call.

GXLEdgeClass isSubPackageOf(gc, "isSubPackageOf", javaPackage, javaPackage, GXLFrom(0, -1, GXLSchemaConst::unOrdered),

GXLTO(0, 1, GXLSchemaConst::unOrdered));

GXLEdgeClass isClassOfPackage(gc, "isClassOfPackage", javaClass, javaPackage, GXLFrom(1,-1, GXLSchemaConst::unOrdered),

GXLTo(1, 1, GXLSchemaConst::unOrdered));

GXLEdgeClass isMethodOfClass(gc, "isMethodOfClass", javaMethod, javaClass, GXLFrom(0,-1, GXLSchemaConst::unOrdered),

GXLTo(0, 1, GXLSchemaConst::unOrdered));

Saving a schema

After creating the schema we want to save it to disk. To do so we create a file output stream and call theGXLDocumentmethodstore.

ofstream ofs("javaschema.gxl");

doc.store(ofs);

Access

To retrieve information from a schema it is necessary to find the element, which carries the information. This is either done by iteration or by direct identification via an identifier.

This example shows how to use theGXLEnumDomainIteratorto print the access modifier keywords. First we have to get a reference to the AttributeClassaccModAttr.

try{

GXLNodeClass accModElem = schema.getNodeClassById("accModElement");

GXLAttributeClass accModAttr = accModElem.getAttribute("accessModifier");

}catch(GXLSchemaElementNotFoundException,

GXLMismatchingSchemaElementTypeException){

return 1;

}

Then we retrieve the domain and iterate its components. An iterated element must not be changed during iteration. This will turn the iterator invalid.

(16)

16 Conclusion: Tools and further development

GXLDomain accModDomain = accModAttr.getDomain();

if(accModDomain.isEnumDomain()){

accModEnumDom = (GXLEnumDomain&) accModDomain;

GXLEnumDomainValIterator eValIt(accModEnumDomain);

while(eValIt.hasNext()){

GXLDefaultEnumVal eVal = eValIt.next();

cout <<< GXLUtil::transcode(eVal.getValue()) <<< endl;

} }

Finish Application

Before ending the application the XMLPlatformUtils of XERCES have to be terminated.

XMLPlatformUtils::Terminate();

5 Conclusion: Tools and further development

There are currently four major developments in GXL at the University of Koblenz-Landau.

1. The GXL API will (and already is) used to develop a tool for checking validity and coher- ence of instance and schema GXL-files.

2. A GXL2G tool is currently developed, which will allow to convert GXL-files to .g-files.

This file format is used by the institute for software engeneering at Koblenz for represent- ing TGraphs. This tool will use the GXLAPI for accessing instance and schema documents and enable the reengineering tool GUPRO [3] to access and process data of foreign sources.

3. In near future a tool for schema extraction will be developed. If no schema document exists an appropriate document will be created from an instance file. In conjunction with the GXL2G tool it will allow GUPRO to process almost all GXL documents.

4. During the process of making their tools compatible with GXL (e.g. writing converters between GXL and their own graph-format), a number of new needs for GXL emerged.

Some kinds of information could not be mapped to the GXL syntax, e.g. an explicit order of the stored elements. Ways to make GXL more simple were proposed, adaption of GXL to additional XML-techniques (e.g. XML Schema) was requested. These change requests were collected, evaluated, discussed and partially realized. The result of this work is GXL 1.1. GXL 1.1 comes with an extended and restructured DTD as well as a definition using the XML Schema language, a new graph-schema and metaschema.

(17)

REFERENCES 17

References

[1] The Apache Software FoundationXerces C++ Parser http://xml.apache.org/xerces-c/index.html 11.03.2003 [2] Doxygen

http://www.doxygen.org 8.10.2003

[3] J. Ebert, B. Kullbach, V. Riediger, A. WinterGUPRO - Generic Understanding of Programs, Electronic Notes on Theoretical Computer Science 72

[4] Oliver Heinen: GXL 1.1 - The XML techniques and their effects on GXL 1.1 Koblenz, 29.4.2003

[5] Ric Holt , Andy Schürr, Susan Elliott Sim, Andreas Winter The GXL-Website, http://www.gupro.de/GXL 6.3.2003

[6] W3C- World Wide Web Consortium http://www.w3c.org/dom 11.03.2003 [7] W3C- World Wide Web Consortium

http://www.w3c.org/xml 8.10.2003

[8] Andreas Winter, Bernt Kullbach, Volker Riediger:An overview of the GXL Graph Exchange Language, Springer Verlag: S. Diehl (ed.) Software Visualization · International Seminar Dagstuhl Castle, Germany, May 20-25, 2001 Revised Lectures

[9] Darya Zavgorodnya, Volker Riediger, Andreas Winter:GXL Instance API Koblenz, 22.4.2003

(18)

18 REFERENCES

Appendix A

void runJAVASchema(){

//Create empty schema GXLDocument doc;

GXLGxl gxl = doc.getGXL();

GXLSchema schema(gxl, "partialJAVAschema" );

//Add the new GXLGraphClass which is incident to all GXLGraphElements GXLGraphClass gc(schema, "JAVAgraphClassID", "JAVAGraphClass");

//Create major elements of JAVA

GXLNodeClass javaPackage(gc, "JavaPackage");

GXLNodeClass javaClass(gc, "JavaClass");

GXLNodeClass javaAttribute(gc, "JavaAttribute");

GXLNodeClass javaMethod(gc, "JavaMethod");

//Create super class for labeled elements

GXLNodeClass javaNamedElement(gc, "JavaNamedElement", "javaNamedElement", GXLSchemaConst::abstract);

//Set inheritance relationship

javaPackage.setIsA(JavaNamedElement);

javaClass.setIsA(JavaNamedElement);

javaMethod.setIsA(JavaNamedElement);

javaAttribute.setIsA(JavaNamedElement);

//Create super class for access modified elements

GXLNodeClass accModElement(gc, "accModElement", "accModElement", GXLSchemaConst::abstract);

//Set inheritance relationship for access modified elements javaClass.setIsA(accModElement);

javaMethod.setIsA(accModElement);

javaAttribute.setIsA(accModElement);

//Create values of possible access modifiers

GXLDefaultEnumVal pubMod(schema, "publicModifier", "public");

GXLDefaultEnumVal protMod(schema, "protectedModifier", "protected");

GXLDefaultEnumVal privMod(schema, "privateModifier", "private");

GXLDefaultEnumVal emptyMod(schema, "emptyModifier", "empty");

//Create domain for labeling elements

GXLStringDomain stringDomain(schema, "stringDomainID");

//Create domain for access modification

GXLEnumDomain accessModDomain(schema, "accessModDom", pubMod);

accessModDomain.addValue(protMod);

accessModDomain.addValue(privMod);

accessModDomain.addValue(emptyMod);

(19)

REFERENCES 19

GXLAttributeClass accModAttr;

try{

//Create label attribute

GXLAttributeClass namedAttr(schema, "name", stringDomain, "nameID");

//Create access modification attribute

accModAttr = GXLAttributeClass(schema, "accessModifier", accessModDomain, "accessModifierID");

//Adding attributeclass for labeling

labeledElement.addAttributeClass(labelAttr);

//Adding attributeclass for access modification accModElement.addAttributeClass(namedAttr);

}

catch(GXLDuplicateAttributeClassException& e){

RGINFO(GXLUtil::transcode(e.msg()));

}

//Set cardinality and ordering for isSubPackageOf association GXLFrom fromSubPackageEdge(0, -1, GXLSchemaConst::unOrdered);

GXLTo toSuperPackageEdge(0, 1, GXLSchemaConst::unOrdered);

//Create isSubPackageOf association

GXLEdgeClass isSubPackageOf(gc, "isSubPackageOf", javaPackage, javaPackage, fromSubPackageEdge, toSuperPackageEdge);

//Set cardinality and ordering for isClassOfPackage association GXLFrom fromClassEdge(1,-1, GXLSchemaConst::unOrdered);

GXLTo toPackageEdge(1, 1, GXLSchemaConst::unOrdered);

//Create isClassOfPackage association

GXLEdgeClass isClassOfPackage(gc, "isClassOfPackage", javaClass, javaPackage, fromClassEdge, toPackageEdge);

//Set cardinality and ordering for isMethodOfClass association GXLFrom fromClassMethod(0,-1, GXLSchemaConst::unOrdered);

GXLTo toClassEdge(0, 1, GXLSchemaConst::unOrdered);

//Create isMethodOfClass association

GXLEdgeClass isMethodOfClass(gc, "isMethodOfClass", javaMethod, javaClass, fromClassEdge, toClassEdge);

//Save schema to file javaschema.gxl ofstream ofs("javaschema.gxl");

doc.store(ofs);

GXLDomain accModDomain = accModAttr.getDomain();

if(accModDomain.isEnum()){

GXLEnumDomain accModEnumDomain = (GXLEnumDomain&) accModDomain;

GXLEnumDomainValIterator eValIt(accModEnumDomain);

while(eValIt.hasNext()){

GXLDefaultEnumVal eVal = eValIt.next();

cout << GXLUtil::transcode(eVal.getValue()) << endl;

} } }

(20)

20 REFERENCES

int main(int argc, char *argv[]) { // Initialize the XML4C system

try {

RGLOG(1, "Initialize XML4C");

XMLPlatformUtils::Initialize();

}

catch (const XMLException& e) { cerr << e;

throw;

}

runJAVASchema();

RGLOG(1, "Terminate XML4C");

XMLPlatformUtils::Terminate();

return 0;

}

Abbildung

Figure 1: Layering of the GXL Schema API architecure
Figure 2: GXL Graph Model (graph part)
Figure 3: GXL Graph Model (value part)
Figure 6: GXL-metaschema: graph part
+4

Referenzen

ÄHNLICHE DOKUMENTE

Theorem 5.1 presents two formulas: The first formula is for the T -equivariant Chow class of a generic T -orbit closure in the Grassmannian, and the second formula is for

For field uses, the annotated expression contains the compile-time type of the instance expression, which determines the class containing the declaration of the accessed field..

•  During program execution, objects of declared classes are created (instances).. •  Classes cannot be modified

• features of general class also implicitly specified for specific class. • implies substitutability (in the sense of Liskov

Validating the performance of a thread-safe class is challenging because it requires diverse workloads that use the class, because existing performance analysis techniques focus

As an illustration of the relationship between the fraction of people possessing income y and the deprivation of an individual lacking y, consider a population (reference group) of

Definition 2.8 • Given two surreal numbers a, b ∈ No, we define their concate- nation a N b as the juxtaposition of their sign sequences.. As in [Kuh00, Remark 3.20], we introduce

In addition to adjectives similar to -er English nouns, some other participial forms of verbs from Arabic, Persian and many from Urdu also take a genitive marked subject argument