[isidorus-cvs] r32 - in trunk: docs src/ajax/javascripts src/json src/rest_interface src/unit_tests src/xml

Lukas Giessmann lgiessmann at common-lisp.net
Sun May 31 13:08:01 UTC 2009


Author: lgiessmann
Date: Sun May 31 09:08:00 2009
New Revision: 32

Log:
some fixes in the json-tmcl module and the json-data-model, some new developments in the ajax module

Added:
   trunk/docs/JSON_model.pdf   (contents, props changed)
Modified:
   trunk/docs/xtm_json.txt
   trunk/src/ajax/javascripts/constants.js
   trunk/src/ajax/javascripts/create.js
   trunk/src/ajax/javascripts/datamodel.js
   trunk/src/json/json_tmcl.lisp
   trunk/src/json/json_tmcl_validation.lisp
   trunk/src/rest_interface/set-up-json-interface.lisp
   trunk/src/unit_tests/poems.xtm
   trunk/src/xml/setup.lisp

Added: trunk/docs/JSON_model.pdf
==============================================================================
Binary file. No diff available.

Modified: trunk/docs/xtm_json.txt
==============================================================================
--- trunk/docs/xtm_json.txt	(original)
+++ trunk/docs/xtm_json.txt	Sun May 31 09:08:00 2009
@@ -1,4 +1,4 @@
-//+-----------------------------------------------------------------------------
+//+-----------------------------------------------------------------------------
 //+ Overview:
 //+  *Part 1: XTM - data model
 //+  *Part 2: Object summaries
@@ -6,8 +6,6 @@
 //+-----------------------------------------------------------------------------
 
 
-
-
 //+-----------------------------------------------------------------------------
 //+ Part 1: XTM - data model:
 //+   The first part describes the xtm's data model, here will be all elements
@@ -112,7 +110,6 @@
   "roles" : [ { <role> }, { <...> } ]
 }
 
-
 //+-----------------------------------------------------------------------------
 //+ topicStub
 //+-----------------------------------------------------------------------------
@@ -173,7 +170,6 @@
 }
 
 
-
 //+-----------------------------------------------------------------------------
 //+ Part 3: TMCL - data model
 //+   This part explains how the tmcl-rules/suggestions of isidorus are
@@ -198,13 +194,13 @@
 //+    constraint, a cardMin member with the minimum cardinality of
 //+    the referenced element which is represented as an unsignedInt
 //+    and a cardMax member which describes the maximum cardinality of this
-//+    element, this member contains an unsigendInt or the string
+//+    element, this member contains an unsignedInt or the string
 //+    "MAX_INT".
 //+-----------------------------------------------------------------------------
 {
   "regexp" : "regular expression",
   "cardMin" : "unsigned integer in string representation",
-  "cardMax" : "unsigend integer in string representation or the string MAX_INT"
+  "cardMax" : "unsigned integer in string representation or the string MAX_INT"
 }
 
 
@@ -214,7 +210,7 @@
 //+    subjectIdentifier, a cardMin member with the minimum cardinality of
 //+    this subjectIdentifier in a topic which is represented as an unsignedInt
 //+    and a cardMax member which describes the maximum cardinality of this
-//+    subjectIdentifier, this member contains an unsigendInt or the string
+//+    subjectIdentifier, this member contains an unsignedInt or the string
 //+    "MAX_INT".
 //+-----------------------------------------------------------------------------
 <simpleConstraint>
@@ -226,7 +222,7 @@
 //+    subjectLocator, a cardMin member with the minimum cardinality of
 //+    this subjectLocator in a topic which is represented as an unsignedInt
 //+    and a cardMax member which describes the maximum cardinality of this
-//+    subjectLocator, this member contains an unsigendInt or the string
+//+    subjectLocator, this member contains an unsignedInt or the string
 //+    "MAX_INT".
 //+-----------------------------------------------------------------------------
 <simpleConstraint>
@@ -246,7 +242,7 @@
 {
   "scopeTypes" : [ [ [ "psi-1-1", "psi-1-2", "..." ], [ "subtype-psi-1", "..." ], <...> ], [ "psi-2-1" "..."], <...> ],
   "cardMin" : "unsigned integer in string representation",
-  "cardMax" : "unsigend integer in string representation or the string MAX_INT"
+  "cardMax" : "unsigned integer in string representation or the string MAX_INT"
 }
 
 
@@ -254,13 +250,20 @@
 //+ topicNameConstraint
 //+    nametypescope constains the original nametype and all valid subtypes
 //+    with the specific scope constraints.
-//+    constriants contains the constraints for the owner topic.
+//+    constraints contains the constraints for the owner topic.
+//+    Note scopeConstraints is a list, because, the can be more scope
+//+    constriants, e.g. one constraints wants 2 scopes of the type "en", and
+//+    "de", and another, wants 3 scopes of the type "fr", "pl" and "sp".
 //+-----------------------------------------------------------------------------
 {
   "nametypescopes" : [ { 
                          "nameType" : [psi-1, psi-2, "..." ],
 			 "scopeConstraints" : [ <scopeConstraints> ]
 		       },
+		       {
+                         "nameType" : [subtype-1-psi-1, subtype-1-psi-2, "..." ],
+			 "scopeConstraints" : [ <scopeConstraints> ]
+		       },
                        <...>
 		     ]
   "constraints" : [ <simpleConstraint>, < ... > ]
@@ -299,10 +302,15 @@
 			  "scopeConstraints" : [ <scopeConstraints> ],
 			  "datatypeConstraint" : "datatype"			  
 			},
+			{
+                          "occurrenceType" : [ "subtype-1-psi-1", "subtype-1-psi-2", "..." ],
+			  "scopeConstraints" : [ <scopeConstraints> ],
+			  "datatypeConstraint" : "datatype"			  
+			},
 			<...>
 		      ],
   "constraints" : [ <simpleConstraints>, <...>],
-  "uniqueConstraint" : [ <uniqueConstraints>, <...> ]
+  "uniqueConstraints" : [ <uniqueConstraints>, <...> ]
 }
 
 
@@ -316,7 +324,7 @@
 {
   "roleType" : [ [ "topic-psi-1", "topic-psi-2", "..." ], ["subtype-1-psi-1", "..."], <...> ],
   "cardMin" : "unsigned integer in string representation",
-  "cardMax" : "unsigend integer in string representation or the string MAX_INT"
+  "cardMax" : "unsigned integer in string representation or the string MAX_INT"
 }
 
 
@@ -335,7 +343,7 @@
   "players" : [ [ "topic-psi-1", "topic-psi-2", "..." ], [ "topic-2-psi-1", "..."], <...> ]
   "roleTypes" : [ [ "topic-psi-1", "topic-psi-2", "..." ], [ "subtype-psi-1", "..." ], <...> ],
   "cardMin" : "unsigned integer in string representation",
-  "cardMax" : "unsigend integer in string representation or the string MAX_INT"
+  "cardMax" : "unsigned integer in string representation or the string MAX_INT"
 }
 
 
@@ -353,7 +361,7 @@
   "otherRoleType" : [ "topic-psi-1", "topic-psi-2", "..." ],
   "otherPlayerType" : [ "topic-psi-1", "topic-psi-2", "..." ],
   "cardMin" : "unsigned integer in string representation",
-  "cardMax" : "unsigend integer in string representation or the string MAX_INT"
+  "cardMax" : "unsigned integer in string representation or the string MAX_INT"
 }
 
 
@@ -368,6 +376,7 @@
 //+    associationTypeScopes contains all available scopes for this association.
 //+-----------------------------------------------------------------------------
 {
+  "associationType" : [ "topic-psi-1", "topic-psi-2" ],
   "associationRoleConstraints" : [ <associationRoleConstraint>, <...> ],
   "rolePlayerConstraints" : [ <rolePlayerConstraints>, <...> ],
   "otherRoleConstraints" : [ <otherRoleConstraint>, <...> ],
@@ -378,6 +387,8 @@
 //+-----------------------------------------------------------------------------
 //+ topicConstraint
 //+    The topicConstraint contains the members:
+//+    *exclusiveInstances which contains a topic-list of topic-psis depending
+//+     on the users exclusive-instance-constraints
 //+    *subjectIdentifierConstraints which defines the subjectIdentifiers
 //+    *subjectLocatorConstraints which defines the subjectLocators
 //+    *topicNameConstraints which defines the topic names
@@ -398,9 +409,7 @@
 //+-----------------------------------------------------------------------------
 //+ fragmentConstraint
 //+    This JSON-Object contains all constraints necessary for an entire
-//+    fragment but not the exclusive-instance-constraint.
-//+    The exclusive-instance-constraint should be sent before a
-//+    fragmentConstraint separately.
+//+    fragment.
 //+    topicConstraint contains an object with all constraints of all baseTypes
 //+    of the mainTopic.
 //+    associationConstraints contains a list of all association constraints

Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js	(original)
+++ trunk/src/ajax/javascripts/constants.js	Sun May 31 09:08:00 2009
@@ -59,10 +59,18 @@
 	       "__trShowHiddenRows__" : "showHiddenRows",
 	       "__trTypeFrame__" : "typeFrame",
 	       "__divScopeFrame__" : "scopeFrame",
+	       "__divScopeContainer__" : "scopeContainer",
 	       "__divValueFrame__" : "valueFrame",
 	       "__divVariantFrame__" : "variantFrame",
 	       "__divVariantContainer__" : "variantContainer",
 	       "__divDatatypeFrame__" : "datatypeFrame",
+	       "__divOccurrenceContainer__" : "occurrenceContainer",
+	       "__divOccurrenceFrame__" : "occurrenceFrame",
+	       "__divAssociationContainer__" : "associationContainer",
+	       "__divAssociationFrame__" : "associationFrame",
+	       "__divRoleContainer__" : "roleContainer",
+	       "__divRoleFrame__" : "roleFrame",
+	       "__divPlayerFrame__" : "playerFrame",
 
 	       "page" : function(){ return this.__divPage__; },
 	       "subPage" : function(){ return this.__divSubPage__; },
@@ -88,8 +96,16 @@
 	       "showHiddenRows" : function(){ return this.__trShowHiddenRows__; },
 	       "typeFrame" : function(){ return this.__trTypeFrame__; },
 	       "scopeFrame" : function(){ return this.__divScopeFrame__; },
+	       "scopeContainer" : function(){ return this.__divScopeContainer__; },
 	       "valueFrame" : function(){ return this.__divValueFrame__; },
 	       "variantFrame" : function(){ return this.__divVariantFrame__; },
 	       "variantContainer" : function(){ return this.__divVariantContainer__; },
-	       "datatypeFrame" : function(){ return this.__divDatatypeFrame__; }
+	       "datatypeFrame" : function(){ return this.__divDatatypeFrame__; },
+	       "occurrenceContainer" : function(){ return this.__divOccurrenceContainer__; },
+	       "occurrenceFrame" : function(){ return this.__divOccurrenceFrame__; },
+	       "associationContainer" : function(){ return this.__divAssociationContainer__; },
+	       "associationFrame" : function(){ return this.__divAssociationFrame__; },
+	       "roleContainer" : function(){ return this.__divRoleContainer__; },
+	       "roleFrame" : function(){ return this.__divRoleFrame__; },
+	       "playerFrame" : function(){ return this.__divPlayerFrame__; }
 	      };
\ No newline at end of file

Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js	(original)
+++ trunk/src/ajax/javascripts/create.js	Sun May 31 09:08:00 2009
@@ -31,8 +31,18 @@
 		    items[i].remove();
 		}
 
+		items = $$("li." + CLASSES.associationContainer());
+		for(var i = 0; i != items.length; ++i){
+		    items[i].remove();
+		}
+
 		var topic = new TopicC(null, (constraints ? constraints.topicConstraints : null));
-		context.insert({"after" : new Element("li", {"class" : CLASSES.topicFrame()}).update(topic.getFrame())});
+		var liT = new Element("li", {"class" : CLASSES.topicFrame()}).update(topic.getFrame());
+		context.insert({"after" : liT});
+
+		var associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
+		var liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
+		liT.insert({"after" : liA});
 	    }
 
 	    function onSuccessHandler(xhr){

Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js	(original)
+++ trunk/src/ajax/javascripts/datamodel.js	Sun May 31 09:08:00 2009
@@ -182,6 +182,18 @@
 			       },
 			       "remove" : function(){
 				   this.getFrame().remove();
+			       },
+			       "showRemoveButton" : function(){
+				   try{ this.__remove__.show(); } catch(err) {}
+			       },
+			       "hideRemoveButton" : function(){
+				   try{ this.__remove__.hide(); } catch(err) {}
+			       },
+			       "showAddButton" : function(){
+				   try{ this.__add__.show(); } catch(err) {}
+			       },
+			       "hideAddButton" : function(){
+				   try{ this.__add__.hide(); } catch(err) {}
 			       }});
 
 
@@ -291,36 +303,37 @@
 
 // --- Representation of a subjectLocator and subjectIdentifier frames.
 var IdentifierC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints, cssClass){
-						    $super();
-						    this.__frame__.writeAttribute({"class" : cssClass});
-                                                    this.__containers__ = new Array();
-
-						    try{
-							if((!contents || contents.length === 0) && constraints && constraints.length > 0){
-							    for(var i = 0; i != constraints.length; ++i){
-								this.__containers__.push(new Object());
-								var min = parseInt(constraints[i].cardMin);
-								var max = constraints[i].cardMax !== "MAX_INT" ? parseInt(constraints[i].cardMax) : "*";
-								if(max !== 0){
-								    var cssTitle = "min: " + min + "   max: " + max + "   regular expression: " + constraints[i].regexp;
-								    for(var j = 0; j != (min === 0 ? 1 : min); ++j){
-									var row = new TextrowC("", constraints[i].regexp, this.__containers__[i],
-											       min === 0 ? 1 : min, max === "*" ? -1 : max, cssTitle);
-									this.__error__.insert({"before" : row.getFrame()});
-								    }
+						$super();
+						this.__frame__.writeAttribute({"class" : cssClass});
+                                                this.__containers__ = new Array();
+
+						try{
+						    if((!contents || contents.length === 0) && constraints && constraints.length > 0){
+							for(var i = 0; i != constraints.length; ++i){
+							    this.__containers__.push(new Object());
+							    var min = parseInt(constraints[i].cardMin);
+							    var max = constraints[i].cardMax !== "MAX_INT" ? parseInt(constraints[i].cardMax) : "*";
+							    if(max !== 0){
+								var cssTitle = "min: " + min + "   max: " + max + "   regular expression: " + constraints[i].regexp;
+								for(var j = 0; j != (min === 0 ? 1 : min); ++j){
+								    var row = new TextrowC("", constraints[i].regexp, this.__containers__[i],
+											   min === 0 ? 1 : min, max === "*" ? -1 : max, cssTitle);
+								    this.__error__.insert({"before" : row.getFrame()});
 								}
 							    }
 							}
-							else {
-							    // TODO: check already existing contents and order them to the corresponding fields
-							}
 						    }
-						    catch(err){
-							alert("From IdentifierC(): " + err);
+						    else {
+							// TODO: check already existing contents and order them to the corresponding fields
 						    }
-						},
-						"getContent" : function(unique, removeNull){
-						    var values = new Array();
+						}
+						catch(err){
+						    alert("From IdentifierC(): " + err);
+						}
+					    },
+					    "getContent" : function(unique, removeNull){
+						var values = new Array();
+						try{
 						    for(var i = 0; i != this.__containers__.length; ++i){
 							for(var j = 0; j != this.__containers__[i].__frames__.length; ++j){
 							    if(unique === true && values.indexOf(this.__containers__[i].__frames__[j].getContent()) !== -1) continue;
@@ -328,12 +341,20 @@
 							    values.push(this.__containers__[i].__frames__[j].getContent().strip());
 							}
 						    }
+						}
+						catch(err){
 						    return values;
-						},
-						"isValid" : function(){
-						    // TODO: check the validity of this frame with the passed constraints and return a boolean value
-						    return true;
-						}});
+						}
+						return values;
+					    },
+					    "toJSON" : function(unique, removeNull){
+						var content = this.getContent(unique, removeNull);
+						return content.length === 0 ? "null" : content.toJSON();
+					    },
+					    "isValid" : function(){
+						// TODO: check the validity of this frame with the passed constraints and return a boolean value
+						return true;
+					    }});
 
 
 // --- Represantation of a scope frame, doesn't contain SelectrowCs, because the values must be unique!
@@ -361,9 +382,18 @@
 					   this.__contents__ = contents;
 					   if(!contents || contents.length < min) throw "From ScopeC.resetRows(): contents.length (" +
 					       (contents ? contents.length : "null") + ") must be > min (" + min + ")!";
-					   if(max !== -1 && (min > max || max === 0))throw "From FrameC(): min must be > max(" + max + ") and > 0 but is " + min;
-					   
+					   if(max !== -1 && min > max)throw "From FrameC(): min must be > max(" + max + ") and > 0 but is " + min;
 
+					   // --- creates an empty div element
+					   if(max === 0){
+					       this.getFrame().update("");
+					       var div = new Element("div", {"class" : CLASSES.selectrowWithoutRemoveButton()});
+					       div.insert({"top" : select});
+					       this.getFrame().insert({"bottom" : div});
+					       return;
+					   }
+
+					   // --- creates an array with all available psis
 					   var options = new Array();
 					   for(var i = 0; i != contents.length; ++i){
 					       var topicPsis = new Array();
@@ -378,7 +408,7 @@
 					   function checkValues(myself){
 					       var rows = myself.getFrame().select("div");
 					       var selectedItems = new Array();
-					       // --- collects all old selected values and removes the option elements
+					       // --- collects all old selected values and removes the elements
 					       for(var i = 0; i != rows.length; ++i){
 						   var selects = rows[i].select("select");
 						   if(selects[0].value.strip().length !== 0) selectedItems.push(selects[0].value);
@@ -410,6 +440,23 @@
 						   values = cleanedValues;
 					       }
 
+					       // --- if there is an empty value "" (if cardMin == 0), this value should be the last
+					       // --- in the array (only when there is another value selected)
+					       for(var h = 0; h != rows.length; ++h){
+						   var select = rows[h].select("select")[0].value;
+						   if(select !== ""){
+						       for(var i = 0; i != values.length; ++i){
+							   for(var j = 0; j != values[i].length; ++j){
+							       if(values[i][j].length === 0){
+								   values[i] = values[values.length - 1];
+								   values[values.length - 1] = new Array("");
+							       }
+							   }
+						       }
+						       break;
+						   }
+					       }
+
 					       // --- fills all empty select elements
 					       for(var i = 0; i != rows.length; ++i){
 						   var select = rows[i].select("select")[0];
@@ -506,17 +553,98 @@
 					       addHandlers(this);
 					   }
 				       },
+				       "isUsed" : function(){
+					   return this.getContent(true, true).length !== 0;
+				       },
 				       "getContent" : function(unique, removeNull){
-					   // --- unique and removeNull aren't be used, they exist only for consistency
 					   var values = new Array();
-					   var rows = this.getFrame().select("div");
-					   for(var i = 0; i != rows.length; ++i){
-					       values.push(new Array(rows[i].select("select")[0].value)); // must be a list of lists
+					   try{
+					       var rows = this.getFrame().select("div");
+					       for(var i = 0; i != rows.length; ++i){
+						   var select = rows[i].select("select")[0].value;
+						   if(unique === true && values.indexOf(select) !== -1) continue;
+						   if(removeNull === true && select.length === 0) continue;
+						   values.push(select);
+					       }
+					   }
+					   catch(err){
+					       return new Array();
 					   }
 					   return values;
-				       }
-				      });
+				       }});
+
+
+
+// --- Contains all scope frames of an element (there can be more than one scope constraint)
+var ScopeContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints){
+                                                    $super();
+                                                    this.__frame__.writeAttribute({"class" : CLASSES.scopeContainer()});
+                                                    this.__container__ = new Array();
+                                                    this.resetValues(contents, constraints);
+                                                },
+						"resetValues" : function(contents, constraints){
+						    try{
+							for(var i = 0; i != this.__container__.length; ++i){
+							    this.__container__[i].remove();
+							}
+							this.__container__ = new Array();
+						    }
+						    catch(err){
+							this.__container__ = new Array();
+						    }
 
+						    // --- sets contents corresponding to the passed constraints
+						    if(constraints && constraints.length){
+							for(var i = 0; i != constraints.length; ++i){
+							    var scopeTypes = constraints[i].scopeTypes;
+							    var min = parseInt(constraints[i].cardMin);
+							    var max = constraints[i].cardMax !== "MAX_INT" ? parseInt(constraints[i].cardMax) : "*";
+							    
+							    // TODO: check and adds contents to the types
+							    
+							    // --- if min === 0 && there is no content, adds an empty option
+							    if(min === 0){ // TODO: check contents of this type
+								scopeTypes.unshift(new Array(new Array(""))); // [[""]]
+							    }
+							    this.__container__.push(new ScopeC(scopeTypes, min === 0 ? 1 : min, max === "*" ? -1 : max));
+							    this.__error__.insert({"before" : this.__container__[this.__container__.length - 1].getFrame()});
+							}
+						    }
+						    else {
+							this.getFrame().insert({"top" : new Element("div", {"class" : CLASSES.selectrowWithoutRemoveButton()})});
+						    }  
+						},
+						"isUsed" : function(){
+						    for(var i = 0; i != this.__container__.length; ++i){
+							if(this.__container__[i].isUsed() === true) return true;
+						    }
+						    return false;
+						},
+						"isValid" : function(){
+						    for(var i = 0; i != this.__container__.length; ++i){
+							if(this.__container__[i].isUsed() === true) return true;
+						    }
+						    return false;
+						},
+						"getContent" : function(){
+						    var values = new Array();
+						    try{
+						    for(var i = 0; i != this.__container__.length; ++i){
+							var cValues = this.__container__[i].getContent(true, true);
+							for(var j = 0; j != cValues.length; ++j){
+							    if(values.indexOf(cValues[j]) !== -1) continue;
+							    values.push(cValues[j]);
+							}
+						    }
+						    }catch(err){
+							return new Array();
+						    }
+						    return values;
+						},
+						"toJSON" : function(){
+						    if(this.getContent().length === 0) return "null";
+						    return this.getContent().toJSON();
+						}});
 
 
 // --- Representation of a variant element
@@ -539,27 +667,10 @@
 						 // --- scopes
 						 this.__scopes__ = null;
 						 //TODO: implement -> also in the server
-						 this.__table__.insert({"bottom" : newRow(CLASSES.scopeFrame(), "Scope", new Element("div"))});
-						 
-						 // --- resourceValue
-						 var value = "";
-						 var datatype = "";
-						 if(contents && contents.resourceRef && contents.resourceRef.length !== 0){
-						     value = contents.resourceRef;
-						     datatype = ANY_URI;
-						 }
-						 else if(contents && contents.resourceData){
-						     value = contents.resourceData.value;
-						     datatype = contents.resourceData.datatype;
-						 }
-						 
-						 this.__value__ = new Element("textarea", {"rows" : 3}).update(value);
-						 this.__table__.insert({"bottom" : newRow(CLASSES.valueFrame(), "Resource Value", this.__value__)});
+						 this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", new Element("div"))});
 						 
-						 // --- datatype
-						 this.__datatype__ = new Object();
-						 new TextrowC(datatype, ".*", this.__datatype__, 1, 1, null);
-						 this.__table__.insert({"bottom" : newRow(CLASSES.datatypeFrame(), "Datatype", this.__datatype__.__frames__[0].getFrame())});
+						 // --- resource value and datatype
+						 makeResource(this, contents, null, null, null);
 						 
 						 // --- minimize
 						 this.minimize();
@@ -633,8 +744,7 @@
 						 if(i === 0) trs[i].show();
 						 else trs[i].hide();
 					     }
-					 }
-					});
+					 }});
 
 
 // --- contains all variants of a name element
@@ -708,10 +818,10 @@
 					      // --- type
 					      var types = new Array();
 					      for(var i = 0; nametypescopes && i !== nametypescopes.length; ++i){
-						  for(j = 0; j != nametypescopes[i].nameType.length; ++j){
+						  for(var j = 0; j != nametypescopes[i].nameType.length; ++j){
 						      types.push(nametypescopes[i].nameType[j]);
 						      if(contents && contents.type && contents.type[0] === nametypescopes[i].nameType[j]){
-							  var sslected = nametypescopes[i].nameType[j];
+							  var selected = nametypescopes[i].nameType[j];
 							  types[types.length - 1] = types[0];
 							  types[0] = selected;
 						      }
@@ -722,29 +832,16 @@
 					      this.__table__.insert({"bottom" : tr});
 					      
 					      // --- scopes
-					      this.__scopes__ = null;
-					      if(nametypescopes && nametypescopes[0].scopeConstraints){
-						  // TODO: pass the selected items seperately to the object, so they can be chosen as default
-						  var scopeTypes = nametypescopes[0].scopeConstraints[0].scopeTypes;
-						  var min = parseInt(nametypescopes[0].scopeConstraints[0].cardMin);
-						  var max = nametypescopes[0].scopeConstraints[0].cardMax !== "MAX_INT" ? parseInt(nametypescopes[0].scopeConstraints[0].cardMax) : "*";
-						  this.__scopes__ = new ScopeC(scopeTypes, min === 0 ? 1 : min, max === "*" ? -1 : max);
-						  tr = newRow(CLASSES.scopeFrame(), "Scope", this.__scopes__.getFrame());
-						  this.__table__.insert({"bottom" : tr});
-					      }
-					      else {
-						  var tr = new Element("tr", {"class" : CLASSES.scopeFrame()});
-						  var tdd = new Element("td", {"class" : CLASSES.description()}).update("Scope");
-						  var tdc = new Element("td", {"class" : CLASSES.content()});
-						  tr.insert({"top" : tdd});
-						  tr.insert({"bottom" : tdc});
-						  this.__table__.insert({"bottom" : tr});
-					      }
-					      
+					      this.__scope__ = new ScopeContainerC(contents && contents.scopes ? scopes : null, nametypescopes && nametypescopes[0].scopeConstraints ? nametypescopes[0].scopeConstraints : null);
+					      this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
+					      onTypeChangeScope(this, contents ? contents.scopes : null, nametypescopes, "name");
+
 					      // --- value
 					      this.__value__ = new Object();
-					      var cssTitleV = "min: " + min + "   max: " + max + "   regular expression: " + (simpleConstraint ? simpleConstraint.regexp : ".*");
-					      new TextrowC((contents && contents.value ? contents.value : ""), (simpleConstraint ? simpleConstraint.regexp : ".*"), this.__value__, 1, 1, cssTitleV);
+					      var _min = parseInt(simpleConstraint.cardMin);
+					      var _max = simpleConstraint.cardMax !== "MAX_INT" ? parseInt(simpleConstraint.cardMax) : "*";
+					      var cssTitleV = "min: " + _min + "   max: " + _max + "   regular expression: " + (simpleConstraint ? simpleConstraint.regexp : ".*");
+					      new TextrowC((contents ? contents.value : ""), (simpleConstraint ? simpleConstraint.regexp : ".*"), this.__value__, 1, 1, cssTitleV);
 					      this.__table__.insert({"bottom" : newRow(CLASSES.valueFrame(), "Value", this.__value__.__frames__[0].getFrame())});
 					      
 					      // --- variants
@@ -772,7 +869,7 @@
 				      "getContent" : function(){
 					  if(this.isUsed() === false) return null;
 					  return {"itemIdentities" : this.__itemIdentity__.getContent(true, true),
-						  "scopes" : this.__scopes__.getContent(),
+						  "scopes" : this.__scope__.getContent(),
 						  "value" : this.__value__.__frames__[0].getContent(),
 						  "variants" : this.__variants__.getContent()};
 				      },
@@ -780,7 +877,7 @@
 					  if(this.isUsed() === false) return "null";
 					  return "{\"itemIdentities\":" + this.__itemIdentity__.toJSON(true, true) +
 					      ",\"type\":[" + this.__type__.__frames__[0].toJSON() +
-					      "],\"scopes\":" + (this.__scopes__ ? this.__scopes__.toJSON() : "null") + 
+					      "],\"scopes\":" + this.__scope__.toJSON() + 
 					      ",\"value\":" + this.__value__.__frames__[0].toJSON() +
 					      ",\"variants\":" + this.__variants__.toJSON() + "}";
 				      },
@@ -789,21 +886,16 @@
 					      this.__value__.__frames__[0].getContent().strip().length !== 0 ||
 					      this.__variants__.getContent().length !== 0;
 				      },
-				      "showRemoveButton" : function(){
-					  this.__remove__.show();
-				      },
-				      "hideRemoveButton" : function(){
-					  this.__remove__.hide();
-				      },
-				      "showAddButton" : function(){
-					  this.__add__.show();
-				      },
-				      "hideAddButton" : function(){
-					  this.__add__.hide();
-				      },
 				      "isValid" : function(){
 					  // TODO: check the content and the constraints + variants.isValid()
 					  return true;
+				      },
+				      "minimize" : function(){
+					  var trs = this.__table__.select("tr");
+					  for(var i = 0; i != trs.length; ++i){
+					      if(i === 0) trs[i].show();
+					      else trs[i].hide();
+					  }
 				      }});
 
 
@@ -824,10 +916,11 @@
 								   var max = constraints[i].constraints[j].cardMax !== "MAX_INT" ? parseInt(constraints[i].constraints[j].cardMax) : "*";
 								   var regexp = constraints[i].constraints[j].regexp;
 								   if(max !== 0){
-								       var title = "min: " + min + "   max: " + max + "   regular expression: " + constraints[i].regexp;
+								       var title = "min: " + min + "   max: " + max + "   regular expression: " + regexp;
 								       var name = new NameC("", constraints[i].nametypescopes, constraints[i].constraints[j],
 											    this.__containers__[i][j], min === 0 ? 1 : min, max === "*" ? -1 : max, title);
 								       this.__error__.insert({"before" : name.getFrame()});
+								       if(min === 0)name.minimize();
 								   }
 							       }
 							   }
@@ -842,31 +935,41 @@
                                                },
 					       "getContent" : function(){
 						   var values = new Array();
-						   for(var i = 0; i != this.__containers__.length; ++i){
-						       for(var j = 0; j != this.__containers__[i].length; ++j){
-							   for(var k = 0; k != this.__containers__[i][j].__frames__.length; ++k){
-							       if(this.__containers__[i][j].__frames__[k].isUsed() === true){
-								   values.push(this.__containers__[i][j].__frames__[k].getContent());
+						   try{
+						       for(var i = 0; i != this.__containers__.length; ++i){
+							   for(var j = 0; j != this.__containers__[i].length; ++j){
+							       for(var k = 0; k != this.__containers__[i][j].__frames__.length; ++k){
+								   if(this.__containers__[i][j].__frames__[k].isUsed() === true){
+								       values.push(this.__containers__[i][j].__frames__[k].getContent());
+								   }
 							       }
 							   }
 						       }
+						       return values;
+						   }
+						   catch(err){
+						       return values;
 						   }
-						   return values;
 						},
 					       "toJSON" : function(){
-						   var str = "[";
-						   for(var i = 0; i != this.__containers__.length; ++i){
-						       for(var j = 0; j != this.__containers__[i].length; ++j){
-							   for(var k = 0; k != this.__containers__[i][j].__frames__.length; ++k){
-							       if(this.__containers__[i][j].__frames__[k].isUsed() === true){
-								   str += this.__containers__[i][j].__frames__[k].toJSON() + ",";
+						   try{
+						       var str = "[";
+						       for(var i = 0; i != this.__containers__.length; ++i){
+							   for(var j = 0; j != this.__containers__[i].length; ++j){
+							       for(var k = 0; k != this.__containers__[i][j].__frames__.length; ++k){
+								   if(this.__containers__[i][j].__frames__[k].isUsed() === true){
+								       str += this.__containers__[i][j].__frames__[k].toJSON() + ",";
+								   }
 							       }
 							   }
 						       }
+						       if(str.endsWith(",")) str = str.slice(0, str.length - 1);
+						       str += "]";
+						       return str === "[]" ? null : str;
+						   }
+						   catch(err){
+						       return "null";
 						   }
-						   if(str.endsWith(",")) str = str.slice(0, str.length - 1);
-						   str += "]";
-						   return str === "[]" ? null : str;
 					       },
 					       "isValid" : function(){
 						   // TODO: check the validity of this frame with the passed constraints and return a boolean value + isValid() of all names
@@ -874,64 +977,208 @@
 					       }});
 
 
+// --- represenation of an occurrence element
+var OccurrenceC = Class.create(ContainerC, {"initialize" : function($super, contents, occurrenceTypes, constraint, uniqueConstraints, owner, min, max, cssTitle){
+                                                $super();
+                                                if(!owner.__frames__) owner.__frames__ = new Array();
+                                                owner.__frames__.push(this);
+                                                this.__frame__.writeAttribute({"class" : CLASSES.occurrenceFrame()});
+                                                this.__table__ = new Element("table", {"class" : CLASSES.occurrenceFrame()});
+                                                this.__frame__.insert({"top" : this.__table__});
 
-var OccurrenceC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints, owner, min, max, cssTitl){
-
-},
+                                                try{
+						    // --- control row + itemIdentity
+						    makeControlRow(this, 5, contents ? contents.itemIdentities : null);
+						    checkRemoveAddButtons(owner, 1, max);
+						    setRemoveAddHandler(this, owner, 1, max, function(){
+							return new OccurrenceC(null, occurrenceTypes, constraint, uniqueConstraints, owner, min, max, cssTitle);
+						    });
+
+						    // --- type
+						    var types = new Array();
+						    for(var i = 0; occurrenceTypes && i !== occurrenceTypes.length; ++i){
+							for(var j = 0; j != occurrenceTypes[i].occurrenceType.length; ++j){
+							    types.push(occurrenceTypes[i].occurrenceType[j]);
+							    if(contents && contents.type && contents.type[0] === ooccurrenceTypes[i].occurrenceType[j]){
+								var selected = occurrenceTypes[i].occurrenceType[j];
+								types[types.length - 1] = types[0];
+								types[0] = selected;
+							    }
+							}
+						    }
+						    this.__type__ = new Object();
+						    var tr = newRow(CLASSES.typeFrame(), "Type", new SelectrowC(types, this.__type__, 1, 1).getFrame());
+						    this.__table__.insert({"bottom" : tr});
+
+						    // --- scopes
+						    this.__scope__ = new ScopeContainerC(contents && contents.scopes ? contents.scopes : null, occurrenceTypes && occurrenceTypes[0].scopeConstraints ? occurrenceTypes[0].scopeConstraints : null);
+						    this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
+						    onTypeChangeScope(this, contents.scopes, occurrenceTypes, "occurrence");
+
+						    // --- resource value and datatype
+						    var _min = parseInt(constraint.cardMin);
+						    var _max = constraint.cardMax !== "MAX_INT" ? parseInt(constraint.cardMax) : "*";
+						    var cssTitle = "min: " + _min + "   max: " + _max + "   regular expression: " + constraint.regexp;
+						    makeResource(this, contents, constraint, (occurrenceTypes ? occurrenceTypes[0].datatypeConstraint : null), cssTitle);
+						}
+                                                catch(err){
+						    alert("From OccurrenceC(): " + err);
+                                                }	 
+                                            },
 					    "getContent" : function(){
-						// TODO: implement
+						if(this.isUsed() === true){
+						    var resourceRef = null;
+						    var resourceData = null;
+						    if(this.__datatype__.__frames__[0].getContent() === ANY_URI){
+							resourceRef = this.__value__.value;
+						    }
+						    else {
+							resourceData = {"datatype" : this.__datatype__.__frames__[0].getContent(),
+									"value" : this.__value__.value};
+						    }
+						    return {"itemIdentities" : this.__itemIdentity__.getContent(true, true),
+							    "type" : [this.__type__.__frames__[0].getContent()],
+							    "scopes" : this.__scope__.getContent(),
+							    "resourceRef" : resourceRef,
+							    "resourceData" : resourceData};
+						}
+						else {
+						    return null;
+						}
 					    },
 					    "toJSON" : function(){
-						// TODO: implement
+						if(this.isUsed() === true){
+						    var resourceRef = "null";
+						    var resourceData = "null";
+						    if(this.__datatype__.__frames__[0].getContent() === ANY_URI){
+							resourceRef = this.__value__.value.toJSON();
+						    }
+						    else {
+							resourceData = "{\"datatype\":" + this.__datatype__.__frames__[0].toJSON() +
+							    ",\"value\":" + this.__value__.value.toJSON() + "}";
+						    }
+						    return "{\"itemIdentities\":" + this.__itemIdentity__.toJSON(true, true) +
+							",\"type\":[" + this.__type__.__frames__[0].toJSON() +
+							"],\"scopes\":" + this.__scope__.toJSON() +
+							",\"resourceRef\":" + resourceRef +
+							",\"resourceData\":" + resourceData + "}";
+						}
+						else {
+						    return "null";
+						}
 					    },
 					    "isUsed" : function(){
-						// TODO: implement
-					    },
-					    "showRemoveButton" : function(){
-						this.__remove__.show();
-					    },
-					    "hideRemoveButton" : function(){
-						this.__remove__.hide();
-					    },
-					    "showAddButton" : function(){
-						this.__add__.show();
-					    },
-					    "hideAddButton" : function(){
-						this.__add__.hide();
+						return this.__itemIdentity__.getContent(true, true).length !== 0 ||
+						    this.__value__.value.strip().length !== 0;
 					    },
 					    "isValid" : function(){
 						// TODO: check the content and the constraints
 						return true;
+					    },
+					    "minimize" : function(){
+						var trs = this.__table__.select("tr");
+						for(var i = 0; i != trs.length; ++i){
+						    if(i === 0) trs[i].show();
+						    else trs[i].hide();
+						}
 					    }});
+			       
 
-
-
+// --- contains all occurrences of an topic element
 var OccurrenceContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints){
-
-},
+						         $super();
+						         this.__containers__ = new Array();
+                                                         this.__frame__.writeAttribute({"class" : CLASSES.occurrenceContainer()});
+
+						         try{
+							     if((!contents || contents.length === 0) && constraints && constraints.length > 0){
+								 for(var i = 0; i != constraints.length; ++i){
+								     this.__containers__.push(new Array());
+								     for(var j = 0; j != constraints[i].constraints.length; ++j){
+									 this.__containers__[i].push(new Object());
+									 var min = parseInt(constraints[i].constraints[j].cardMin);
+									 var max = constraints[i].constraints[j].cardMax !== "MAX_INT" ? parseInt(constraints[i].constraints[j].cardMax) : "*";
+									 var regexp = constraints[i].constraints[j].regexp;
+									 if(max !== 0){
+									     var title = "min: " + min + "   max: " + max + "   regular expression: " + regexp;
+									     var occurrence = new OccurrenceC("", constraints[i].occurrenceTypes, constraints[i].constraints[j],
+													      constraints[i].uniqueConstraints, this.__containers__[i][j],
+													      min === 0 ? 1 : min, max === "*" ? -1 : max, title);
+									     this.__error__.insert({"before" : occurrence.getFrame()});
+									     if(min === 0)occurrence.minimize();
+									 }
+								     }
+								 }
+                                               		     }
+                                               		     else {
+                                               			 // TODO: check already existing contents and order them to the corresponding fields
+                                               		     }
+							 }
+						         catch(err){
+							     alert("From OccurrenceContainerC(): " + err);
+						         }
+						     },
 						     "isValid" : function(){
 							 // TODO: implement this method
 							 return true;
 						     },
 						     "getContent" : function(){
-							 // TODO: implement this method
+							 var values = new Array();
+							 try{
+							     for(var i = 0; i != this.__containers__.length; ++i){
+								 for(var j = 0; j != this.__containers__[i].length; ++j){
+								     for(var k = 0; k != this.__containers__[i][j].__frames__.length; ++k){
+									 if(this.__containers__[i][j].__frames__[k].isUsed() === true){
+									     values.push(this.__containers__[i][j].__frames__[k].getContent());
+									 }
+								     }
+								 }
+							     }
+							     return values;
+							 }
+							 catch(err){
+							     return values;
+							 }
 						     },
-						     "toJSON" : function(){
-							 // TODO: implement this method
+						     "toJSON" : function(){							 
+							 try{
+							     var str = "[";
+							     for(var i = 0; i != this.__containers__.length; ++i){
+								 for(var j = 0; j != this.__containers__[i].length; ++j){
+								     for(var k = 0; k != this.__containers__[i][j].__frames__.length; ++k){
+									 if(this.__containers__[i][j].__frames__[k].isUsed() === true){
+									     str += this.__containers__[i][j].__frames__[k].toJSON() + ",";
+									 }
+								     }
+								 }
+							     }
+							     if(str.endsWith(",")) str = str.slice(0, str.length - 1);
+							     str += "]";
+							     return str === "[]" ? null : str;
+							 }
+							 catch(err){
+							     return "null";
+							 }
 						     }});
 						    
 
-
-
-
+// --- representation of a topic element.
 var TopicC = Class.create(ContainerC, {"initialize" : function($super, content, constraints){
                                            $super();
+                                           this.__minimized__ = false;
                                            try{
 					       this.__frame__ .writeAttribute({"class" : CLASSES.topicFrame()});
 					       this.__table__ = new Element("table", {"class" : CLASSES.topicFrame()});
 					       this.__frame__.insert({"top" : this.__table__});
-					       this.__caption__ = new Element("caption").update("Topic");
+					       this.__caption__ = new Element("caption", {"class" : CLASSES.clickable()}).update("Topic");
 					       this.__table__.insert({"top" : this.__caption__});
+
+					       function setMinimizeHandler(myself){
+						   myself.__caption__.observe("click", function(event){
+						       myself.minimize();
+						   });
+					       }
+					       setMinimizeHandler(this);
 					       
 					       // --- topic id
 					       this.__topicid__ = new Object();
@@ -960,32 +1207,328 @@
 					       this.__name__ = new NameContainerC(_contents, _constraints);
 					       this.__table__.insert({"bottom" : newRow(CLASSES.nameContainer(), "Names", this.__name__.getFrame())});
 					       
-					       
-
-
-
+					       // --- occurrences
+					       _contents = (content ? content.occurrences : null);
+					       _constraints = (constraints ? constraints.topicOccurrenceConstraints : null);
+					       this.__occurrence__ = new OccurrenceContainerC(_contents, _constraints);
+					       this.__table__.insert({"bottom" : newRow(CLASSES.occurrenceContainer(), "Occurrences", this.__occurrence__.getFrame())});
 
 
 
 
 
-					       var tmp = new Element("input", {"type" : "button", "value" : "test"});
-					       function tester(myself){
-						   tmp.observe("click", function(event){
-						       //alert(myself.__subjectLocator__.getContent() + " -> " + myself.__subjectLocator__.toJSON() + "\n\n" + myself.__subjectLocator__.getContent(true, true) + " -> " + myself.__subjectLocator__.toJSON(true, true));
-						       
-						   });
-					       };
-					       tester(this);
-					       this.__frame__.insert({"bottom" : tmp});
+					       var btn = new Element("input", {"value" : "topic.toJSON()", "type" : "button"});
+					       function addBtnHandler(myself){
+						   btn.observe("click", function(event){
+						       alert(myself.toJSON());
+						   })
+					       }
+					       addBtnHandler(this);
+					       this.__frame__.insert({"bottom" : btn});
 					   }catch(err){
 					       alert("From TopciC(): " + err);
 					   }
                                        },
+				       "isValid" : function(){
+					   // TODO: implement
+					   return true;
+				       },
 				       "getContent" : function(){
-					   return {"id" : this.__topicid__.__frames__[0].getContent };
-				       }
-				      });
+					   try{
+					   return {"id" : this.__topicid__.__frames__[0].getContent().strip(),
+						   "itemIdentities" : this.__itemIdentity__.getContent(true, true),
+						   "subjectLocators" : this.__subjectLocator__.getContent(true, true),
+						   "subjectIdentifiers" : this.__subjectIdentifier__.getContent(true, true),
+						   "names" : this.__name__.getContent(),
+						   "occurrences" : this.__occurrence__.getContent()};
+					   }
+					   catch(err){
+					       return null;
+					   }
+				       },
+				       "toJSON" : function(){
+					   try{
+					       return "{\"id\":" + this.__topicid__.__frames__[0].getContent().strip().toJSON() +
+						   ",\"itemIdentities\":" + this.__itemIdentity__.toJSON(true, true) + 
+						   ",\"subjectLocators\":" + this.__subjectLocator__.toJSON(true, true) +
+						   ",\"subjectIdentifiers\":" + this.__subjectIdentifier__.toJSON(true, true) +
+						   ",\"names\":" + this.__name__.toJSON() +
+						   ",\"occurrences\":" + this.__occurrence__.toJSON() + "}";
+					   }
+					   catch(err){
+					       return "null";
+					   }
+				       },
+				       "minimize" : function(){
+					   var rows = new Array();
+					   rows.push(this.getFrame().select("tr." + CLASSES.topicIdFrame())[0],
+						     this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0],
+						     this.getFrame().select("tr." + CLASSES.subjectLocatorFrame())[0],
+						     this.getFrame().select("tr." + CLASSES.subjectIdentifierFrame())[0],
+						     this.getFrame().select("tr." + CLASSES.nameContainer())[0],
+						     this.getFrame().select("tr." + CLASSES.occurrenceContainer())[0]);
+					   for(var i = 0; i != rows.length; ++i){
+					       if(this.__minimized__ === false) rows[i].hide();
+					       else rows[i].show();
+					   }
+					   this.__minimized__ = !this.__minimized__;
+				       }});
+
+
+// --- representation of a role element.
+var RoleC = Class.create(ContainerC, {"initialize" : function($super, itemIdentities, roleTypes, rolePlayers, owner, min, max){
+				          $super();
+				          if(!owner.__frames__) owner.__frames__ = new Array();
+                                          if(!roleTypes || roleTypes.length === 0) throw "From RoleC(): roleTypes must be set!";
+                                          if(!rolePlayers || rolePlayers.length === 0) throw "From RoleC(): rolePalyers must be set";
+				          owner.__frames__.push(this);
+				          this.__frame__.writeAttribute({"class" : CLASSES.roleFrame()});
+				          this.__table__ = new Element("table", {"class" : CLASSES.roleFrame()});
+				          this.__frame__.insert({"top" : this.__table__});
+                                          this.__roleTypes__ = roleTypes;
+                                          this.__rolePlayers__ = rolePlayers;
+    
+				          try{
+					      // --- control row + itemIdentity
+					      makeControlRow(this, 3, itemIdentities); // make control row have to be changed to a separate control row for roles
+					      checkRemoveAddButtons(owner, 1, max);
+					      setRemoveAddHandler(this, owner, 1, max, function(){
+						  return new RoleC(null, roleTypes, rolePlayers, owner, min, max);
+					      });
+
+					      // --- type
+					      var types = this.__roleTypes__.flatten();
+					      this.__type__ = new Object();
+					      var tr = newRow(CLASSES.typeFrame(), "Type", new SelectrowC(types, this.__type__, 1, 1).getFrame());
+					      this.__table__.insert({"bottom" : tr});
+
+					      // --- player
+					      var players = this.__rolePlayers__.flatten();
+					      this.__player__ = new Object();
+					      tr = newRow(CLASSES.playerFrame(), "Player", new SelectrowC(players, this.__player__, 1, 1).getFrame());
+					      this.__table__.insert({"bottom" : tr});
+					  }
+				          catch(err){
+					      alert("From RoleC(): " + err);
+					  }
+				      },
+				      "getType" : function(){
+					  return this.__type__.__frames__[0].getContent();
+				      },
+				      "getPlayer" : function(){
+					  return this.__player__.__frames__[0].getContent();
+				      },
+				      "getContent" : function(){
+					  if(this.isUsed()){
+					      return {"itemIdentities" : this.__itemIdentity__.getContent(true, true),
+						      "type" : new Array(this.getType()),
+						      "topicRef" : new Array(this.getPlayer())};
+					  }
+
+					  return null;
+				      },
+				      "toJSON" : function(){
+					  if(this.isUsed()){
+					      return "{\"itemIdentities\":" +  this.__itemIdentity__.toJSON(true, true) +
+						     ",\"type\":[" + this.getType().toJSON() + "]" +
+						     ",\"topicRef\":[" + this.getPlayer().toJSON() + "]}";
+					  }
+
+					  return "null";
+				      },
+				      "isValid" : function(){
+					  return this.getType().length !== 0 && this.getPlayer().length !== 0;
+				      },
+				      "isUsed" : function(){
+					  return this.getType().length !== 0 || this.getPlayer().length !== 0 || this.__itemIdentity__.getContent(true, true).length !== 0;
+				      }});
+
+
+// --- contains all roles of an association
+var RoleContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, roleConstraints, playerConstraints, otherRoleConstraints){
+                                                  $super();
+                                                   this.__frame__.writeAttribute({"class" : CLASSES.roleContainer()});
+                                                   this.__container__ = new Object();
+
+                                                   try{
+						       if((!contents || contents.length === 0) && roleConstraints && playerConstraints){
+							   for(var i = 0; playerConstraints && i !== playerConstraints.length; ++i){
+							       //new RoleC(new Array("itemIdentity " + i), playerConstraints[i].roleTypes, playerConstraints[i].players, this.__container__, 1, 4);
+							       //this.__error__.insert({"before" : this.__container__.__frames__[i].getFrame()});
+							   }
+                                               	       }
+                                               	       else {
+                                               		   // TODO: check already existing contents and order them to the corresponding fields
+                                               	       }
+
+
+						       
+                                                   }
+                                                   catch(err){
+                                               	       alert("From RoleContainerC(): " + err);
+                                                   }
+                                               },
+					       "resetValues" : function(roleConstraints, playerConstraints, otherRoleConstraints){
+						   
+						   // TODO: implement
+					       },
+					       "getContent" : function(){
+						   // TODO: implement
+					       },
+					       "toJSON" : function(){
+						   // TODO: implement
+					       },
+					       "isValid" : function(){
+						   // TODO: implement
+					       },
+					       "isUsed" : function(){
+						   // TODO: implement
+					       }});
+
+
+// --- representation of an association element
+var AssociationC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints, owner){
+					         $super();
+					         if(!owner) throw "From NameC(): owner must be set but is null";
+                                                 if(!owner.__frames__) owner.__frames__ = new Array();
+                                                 owner.__frames__.push(this);
+    
+                                                 this.__frame__.writeAttribute({"class" : CLASSES.associationFrame()});
+                                                 this.__table__ = new Element("table", {"class" : CLASSES.associationFrame()});
+                                                 this.__frame__.insert({"top" : this.__table__});
+                                                 this.__constraints__ = constraints;
+                                                 this.__contents__ = contents;
+
+					         try{
+						     // --- control row + ItemIdentity
+						     makeControlRow(this, 4, contents ? contents.itemIdentities : null);
+						     checkRemoveAddButtons(owner, 1, -1);
+						     setRemoveAddHandler(this, owner, 1, -1, function(){
+							 return new AssociationC(null, constraints, owner);
+						     });
+
+						     // --- type
+						     var types = new Array();
+						     for(var i = 0; constraints && i !== constraints.length; ++i){
+							 for(var j = 0; j != constraints[i].associationType.length; ++j){
+							     types.push(constraints[i].associationType[j]);
+							     if(contents && contents.type && contents.type[0] === constraints[i].associationType[j]){
+								 var selected = constraints[i].associationType[j];
+								 types[types.length - 1] = types[0];
+								 types[0] = selected;
+							     }
+							 }
+						     }
+						     this.__type__ = new Object();
+						     var tr = newRow(CLASSES.typeFrame(), "Type", new SelectrowC(types, this.__type__, 1, 1).getFrame());
+						     this.__table__.insert({"bottom" : tr});
+						     
+						     // --- scopes
+						     this.__scope__ = new ScopeContainerC(this.__contents__ && this.__contents__.scopes ? this.__contents__.scopes : null, this.__constraints__ && this.__constraints__[0].scopeConstraints ? this.__constraints__[0].scopeConstraints : null);
+						     this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
+
+						     // --- roles
+						     var _roleConstraints = _playerConstraints = _otherRoleConstraints = null;
+						     if(this.__constraints__){
+							 _roleConstraints = this.__constraints__[0].associationRoleConstraints;
+							 _playerConstraints = this.__constraints__[0].rolePlayerConstraints;
+							 _otherRoleConstraints = this.__constraints__[0].otherRoleConstraints;
+						     }
+
+						     this.__roles__ = new RoleContainerC(this.__contents__ ? this.__contents__.roles : null, _roleConstraints, _playerConstraints, _otherRoleConstraints);
+						     this.__table__.insert({"bottom" : newRow(CLASSES.roleContainer(), "Roles", this.__roles__.getFrame())});
+						     
+						     // --- registers the onChangeHandler of the Type-selectrow
+						     onTypeChangeScope(this, null, null, "association");
+						 }
+					         catch(err){
+						     alert("From AssociationC(): " + err);
+						 }
+					     },
+					     "resetValues" : function(){
+						 // --- scope, depends only to the associationtype, roles can be ignored				 
+						 // --- finds the scopes depending to the selected type
+						 var foundIdx = -1;
+						 for(var i = 0; this.__constraints__ && i != this.__constraints__.length; ++i)
+						 {
+						     if(foundIdx !== -1) break;
+						     for(var j = 0; j != this.__constraints__[i].associationType.length; ++j){
+							 if(this.__type__.__frames__[0].getContent() === this.__constraints__[i].associationType[j]){
+							     foundIdx = i;
+							     break;
+							 }
+						     }
+						 }
+						 this.__scope__.resetValues(null, (foundIdx === -1 ? null : this.__constraints__[foundIdx].scopeConstraints));
+
+						 var _roleConstraints = _playerConstraints = _otherRoleConstraints = null;
+						 if(foundIdx !== -1){
+						     _roleConstraints = this.__constraints__[foundIdx].associationRoleConstraints;
+						     _playerConstraints = this.__constraints__[foundIdx].rolePlayerConstraints;
+						     _otherRoleConstraints = this.__constraints__[foundIdx].otherRoleConstraints;
+						 }
+						 this.__roles__.resetValues(_roleConstraints, _playerConstraints, _otherRoleConstraints);
+					     },
+					     "getContent" : function(){
+						 // TODO: implement
+					     },
+					     "toJSON" : function(){
+						 // TODO: implement
+					     },
+					     "isValid" : function(){
+						 // TODO: implement
+					     },
+					     "isUsed" : function(){
+						 // TODO: implement
+					     }});
+
+
+var AssociationContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints){
+						          $super();
+						          this.__minimized__ = false;
+						          try{
+							      this.__frame__ .writeAttribute({"class" : CLASSES.associationContainer()});
+							      this.__table__ = new Element("table", {"class" : CLASSES.associationContainer()});
+							      this.__frame__.insert({"top" : this.__table__});
+							      this.__caption__ = new Element("caption", {"class" : CLASSES.clickable()}).update("Associations");
+							      this.__table__.insert({"top" : this.__caption__})
+
+							      this.__container__ = new Object();
+
+							      for(var i = 0; contents && i != contents.length; ++i){
+								  var association = new AssociationC(contents[i], constraints, this.__container__);
+								  var tr = new Element("tr", {"class" : CLASSES.associationFrame()});
+								  var td = new Element("td", {"class" : CLASSES.content()});
+								  td.update(association.getFrame());
+								  tr.update(td);
+								  this.__table__.insert({"bottom" : tr});
+							      }
+
+							      if(!this.__container__.__frames__ && constraints && constraints.length !== 0){
+								  var association = new AssociationC(null, constraints, this.__container__);
+								  var tr = new Element("tr", {"class" : CLASSES.associationFrame()});
+								  var td = new Element("td", {"class" : CLASSES.content()});
+								  td.update(association.getFrame());
+								  tr.update(td);
+								  this.__table__.insert({"bottom" : tr});
+							      }
+							  }
+						          catch(err){
+							      alert("From AssociationContainerC(): " + err);
+							  }
+						      },
+						      "getContent" : function(){
+							  // TODO: implement
+						      },
+						      "toJSON" : function(){
+							  // TODO: implement
+						      },
+						      "isValid" : function(){
+							  // TODO: implement
+						      },
+						      "minimize" : function(){
+							  // TODO: implement
+						      }});
 
 
 
@@ -1155,4 +1698,101 @@
 	    else trs[i].hide();
 	}
     });
+}
+
+
+// --- This function adds a onchange handler to the type-selct-element
+// --- of the instance passed through the variable myself.
+// --- On changing there will be reset the scope frame to the corresponding
+// --- type and when what is set to "occurrence" there will be set a corresponding
+// --- datatype-value.
+function onTypeChangeScope(myself, contents, constraints, what){
+    try{
+	var select = myself.__table__.select("tr." + CLASSES.typeFrame())[0].select("td." + CLASSES.content())[0].select("select")[0];
+	select.observe("change", function(event){
+	    var type = event.element().value;
+	    
+	    var foundIdx = -1;
+	    if(what === "name"){
+		for(var i = 0; constraints && i !== constraints.length; ++i){
+		    if(foundIdx !== -1) break;
+		    for(var j = 0; j !== constraints[i].nameType.length; ++j){
+			if(foundIdx !== -1) break;
+			if(constraints[i].nameType[j] === type){
+			    foundIdx = i;
+			    break;
+			}
+		    }
+		}
+		myself.__scope__.resetValues(contents, (foundIdx === -1 ? null : constraints[foundIdx].scopeConstraints));
+	    }
+	    else if(what === "occurrence"){
+		for(var i = 0; constraints && i !== constraints.length; ++i){
+		    if(foundIdx !== -1) break;
+		    for(var j = 0; j !== constraints[i].occurrenceType.length; ++j){
+			if(foundIdx !== -1) break;
+			if(constraints[i].occurrenceType[j] === type){
+			    foundIdx = i;
+			    break;
+			}
+		    }
+		}
+		if(foundIdx !== -1 && constraints[foundIdx].datatypeConstraint){
+		    var dc = constraints[foundIdx].datatypeConstraint;
+		    myself.__datatype__.__frames__[0].getFrame().select("input")[0].writeAttribute({"readonly" : "readonly", "value" : dc});
+		}
+		else {
+		    myself.__datatype__.__frames__[0].getFrame().select("input")[0].writeAttribute({"value" : ""});
+		    myself.__datatype__.__frames__[0].getFrame().select("input")[0].removeAttribute("readonly");
+		}
+		myself.__scope__.resetValues(contents, (foundIdx === -1 ? null : constraints[foundIdx].scopeConstraints));
+	    }
+	    else if(what === "variant"){
+		// do nothing all values will be stored
+	    }
+	    else if(what === "association"){
+		myself.resetValues();
+	    }
+	});
+    }
+    catch(err){}
+}
+
+
+// --- sets the resource value and datatype of names and occurrences
+function makeResource(myself, content, constraints, datatypeConstraint, cssTitle){
+    var value = "";
+    var datatype = "";
+    if(content && content.resourceRef && content.resourceRef.length !== 0){
+	value = content.resourceRef;
+	datatype = ANY_URI;
+    }
+    else if(content && content.resourceData){
+	value = content.resourceData.value;
+	datatype = contents.resourceData.datatype;
+    }
+    
+    try{
+	this.__value__.remove();
+	this.__value__ = null;
+    }catch(err){}
+    try{
+	this.__datatype__.__frames__[0].remove();
+	this.__datytype__ = new Object();
+    }catch(err){}
+
+    myself.__value__ = new Element("textarea", {"rows" : 3}).update(value);
+    myself.__table__.insert({"bottom" : newRow(CLASSES.valueFrame(), "Resource Value", myself.__value__)});
+    if(cssTitle && cssTitle.length !== 0) myself.__value__.writeAttribute({"title" : cssTitle});
+
+    // --- datatype
+    myself.__datatype__ = new Object();
+    if(datatypeConstraint && datatypeConstraint.length !== 0){
+	new TextrowC(datatypeConstraint, datatypeConstraint, myself.__datatype__, 1, 1, null);
+	myself.__datatype__.__frames__[0].getFrame().select("input")[0].writeAttribute({"readonly" : "readonly"});
+    }
+    else {
+	new TextrowC(datatype, ".*", myself.__datatype__, 1, 1, null);
+    }
+    myself.__table__.insert({"bottom" : newRow(CLASSES.datatypeFrame(), "Datatype", myself.__datatype__.__frames__[0].getFrame())});
 }
\ No newline at end of file

Modified: trunk/src/json/json_tmcl.lisp
==============================================================================
--- trunk/src/json/json_tmcl.lisp	(original)
+++ trunk/src/json/json_tmcl.lisp	Sun May 31 09:08:00 2009
@@ -35,7 +35,7 @@
 	     (let ((value
 		    (get-constraints-of-topic topics :treat-as treat-as)))
 	       (concatenate 'string "\"topicConstraints\":" value))))
-	(let ((available-associations ;what's with association which have only a associationrole-constraint?
+	(let ((available-associations ;what's with association which have only a associationrole-constraints?
 	       (remove-duplicates
 		(loop for topic in topics
 		   append (get-available-associations-of-topic topic :treat-as treat-as)))))
@@ -58,40 +58,6 @@
 				"{" topic-constraints "," associations-constraints "}")))
 	      json-string)))))))
 
-;(defun get-constraints-of-fragment(topic-psi &key (treat-as 'type))
-;  (let ((associationtype (get-item-by-psi *associationtype-psi*))
-;	(associationtype-constraint (get-item-by-psi *associationtype-constraint-psi*))
-;	(topic
-;	 (let ((psi
-;		(elephant:get-instance-by-value 'PersistentIdC 'uri topic-psi)))
-;	   (when psi
-;	     (identified-construct psi)))))
-;    (when topic
-;      (let ((topic-constraints
-;	     (let ((value
-;		    (get-constraints-of-topic topic :treat-as treat-as)))
-;	       (concatenate 'string "\"topicConstraints\":" value))))
-;	(let ((available-associations ;what's with association which have only a associationrole-constraint?
-;	       (get-available-associations-of-topic topic :treat-as treat-as)))
-;	  (dolist (item available-associations)
-;	    (topictype-p item associationtype associationtype-constraint))
-;	  (let ((associations-constraints
-;		 (concatenate 'string "\"associationsConstraints\":"
-;			      (let ((inner-associations-constraints "["))
-;				(loop for available-association in available-associations
-;				   do (let ((value
-;					     (get-constraints-of-association available-association)))
-;					(setf inner-associations-constraints
-;					      (concatenate 'string inner-associations-constraints value ","))))
-;				(if (string= inner-associations-constraints "[")
-;				    (setf inner-associations-constraints "null")
-;				    (setf inner-associations-constraints
-;					  (concatenate 'string (subseq inner-associations-constraints 0 (- (length inner-associations-constraints) 1)) "]")))))))
-;	    (let ((json-string
-;		   (concatenate 'string
-;				"{" topic-constraints "," associations-constraints "}")))
-;	      json-string)))))))
-    
 
 ;; =============================================================================
 ;; --- all association constraints ---------------------------------------------
@@ -101,7 +67,10 @@
    passed associationtype-topic."
   (let ((constraint-topics
 	 (get-all-constraint-topics-of-association associationtype-topic)))
-    (let ((associationtypescope-constraints
+    (let ((associationtype
+	   (concatenate 'string "\"associationType\":"
+			(json-exporter::identifiers-to-json-string associationtype-topic)))
+	  (associationtypescope-constraints
 	   (let ((value (get-typescope-constraints associationtype-topic :what 'association)))
 	     (concatenate 'string "\"scopeConstraints\":" value)))
 	  (associationrole-constraints
@@ -117,7 +86,7 @@
 		  (get-otherrole-constraints (getf constraint-topics :otherrole-constraints))))
 	     (concatenate 'string "\"otherRoleConstraints\":" value))))
       (let ((json-string
-	     (concatenate 'string "{" associationrole-constraints "," roleplayer-constraints ","
+	     (concatenate 'string "{" associationtype "," associationrole-constraints "," roleplayer-constraints ","
 			  otherrole-constraints "," associationtypescope-constraints "}")))
 	json-string))))
 
@@ -217,6 +186,7 @@
 			   (uri (first (psis (getf involved-topic-tupple :otherplayer))))
 			   (uri (first (psis (getf involved-topic-tupple :otherrole))))
 			   constraint-lists))
+
 		  (let ((json-player
 			 (concatenate 'string "\"players\":"
 				      (topics-to-json-list
@@ -342,7 +312,9 @@
   "Returns a list of the form
    ((:associationroletype <topic> :card-min <string> :card-max <string>), <...>)
    which describes all associationrole-constraints of the passed
-   constraint-topics."
+   constraint-topics.
+   If as-json is set to t the return value of this function is a json-string otherwise a
+   list of lists of the following form (:roletype <topic, topic, ...> :cardMin <min> :cardMax <max>)"
   (let ((applies-to (get-item-by-psi *applies-to-psi*))
 	(roletype-role (get-item-by-psi *roletype-role-psi*))
 	(constraint-role (get-item-by-psi *constraint-role-psi*))
@@ -366,6 +338,7 @@
 						 associationroletype))
 				     associationrole-constraints))))
 	(let ((cleaned-associationrole-constraints "["))
+	      ;(raw-constraints nil))
 	  (loop for associationroletype-topic in associationroletype-topics
 	     do (let ((constraint-lists
 			    (remove-duplicate-constraints
@@ -385,6 +358,7 @@
 				     "{\"roleType\":" roletype-with-subtypes
 				     ",\"cardMin\":" (getf (first constraint-lists) :card-min)
 				     ",\"cardMax\":" (getf (first constraint-lists) :card-max) "},")))))
+		  
 
 	  (if (string= cleaned-associationrole-constraints "[")
 	      (setf cleaned-associationrole-constraints "null")
@@ -475,41 +449,6 @@
 			  topicoccurrence-constraints "," abstract-constraint "}")))
         json-string))))
 
-;(defun get-constraints-of-topic (topic-instances &key(treat-as 'type))
-;  (let ((constraint-topics
-;	 (get-all-constraint-topics-of-topic topic-instance :treat-as treat-as)))
-;    (let ((exclusive-instance-constraints
-;	   (let ((value
-;		  (get-exclusive-instance-constraints (getf constraint-topics :exclusive-instance-constraints))))
-;	     (concatenate 'string "\"exclusiveInstances\":" value)))
-;	  (subjectidentifier-constraints
-;	   (let ((value
-;		  (get-simple-constraints (getf constraint-topics :subjectidentifier-constraints) :error-msg-constraint-name "subjectidentifier")))
-;	     (concatenate 'string "\"subjectIdentifierConstraints\":" value)))
-;	  (subjectlocator-constraints
-;	   (let ((value
-;		  (get-simple-constraints (getf constraint-topics :subjectlocator-constraints) :error-msg-constraint-name "subjectlocator")))
-;	     (concatenate 'string "\"subjectLocatorConstraints\":" value)))
-;	  (topicname-constraints
-;	   (let ((value
-;		  (get-topicname-constraints (getf constraint-topics :topicname-constraints))))
-;	     (concatenate 'string "\"topicNameConstraints\":" value)))
-;	  (topicoccurrence-constraints
-;	   (let ((value
-;		  (get-topicoccurrence-constraints (getf constraint-topics :topicoccurrence-constraints) 
-;						   (getf constraint-topics :uniqueoccurrence-constraints))))
-;	     (concatenate 'string "\"topicOccurrenceConstraints\":" value)))
-;	  (abstract-constraint
-;	   (concatenate 'string "\"abstractConstraint\":"
-;			(if (getf constraint-topics :abstract-topictype-constraints)
-;			    "true"
-;			    "false"))))
-;      (let ((json-string
-;	     (concatenate 'string "{" exclusive-instance-constraints "," subjectidentifier-constraints
-;			  "," subjectlocator-constraints "," topicname-constraints ","
-;			  topicoccurrence-constraints "," abstract-constraint "}")))
-;        json-string))))
-
 
 (defun get-exclusive-instance-constraints(owner exclusive-instances-lists)
   "Returns a JSON-obejct of the following form:
@@ -745,7 +684,7 @@
 	  (error "found contrary occurrence-datatype-constraints: ~a~%" datatype-constraints))
 	(if datatype-constraint
 	    (json:encode-json-to-string (first datatype-constraint))
-	    nil)))))
+	    "null")))))
 
 
 (defun get-typescope-constraints(element-type-topic &key(what 'topicname))

Modified: trunk/src/json/json_tmcl_validation.lisp
==============================================================================
--- trunk/src/json/json_tmcl_validation.lisp	(original)
+++ trunk/src/json/json_tmcl_validation.lisp	Sun May 31 09:08:00 2009
@@ -241,7 +241,7 @@
 
 (defun list-instances (topic-instance &optional (topictype (get-item-by-psi *topictype-psi*))
                                                 (topictype-constraint (get-item-by-psi *topictype-constraint-psi*)))
-  "Returns the topic-instance, all subtypes found by the function lis-subtypes and all direct
+  "Returns the topic-instance, all subtypes found by the function list-subtypes and all direct
    instances for the found subtypes."
   (let ((all-subtypes-of-this
 	 (getf (list-subtypes topic-instance topictype topictype-constraint) :subtypes))
@@ -262,10 +262,11 @@
 			(remove-duplicates
 			 (loop for subtype in all-instances-of-this
 			    append (getf (list-subtypes subtype nil nil) :subtypes))))))
-	(remove-if #'null
-		   (map 'list #'(lambda(x)
-				  (handler-case (progn
-						  (topictype-of-p x nil)
-						  x)
-				    (condition () nil)))
-			all-subtypes-of-all-instances))))))
\ No newline at end of file
+	(union all-instances-of-this 
+	       (remove-if #'null
+			  (map 'list #'(lambda(x)
+					 (handler-case (progn
+							 (topictype-of-p x nil)
+							 x)
+					   (condition () nil)))
+			       all-subtypes-of-all-instances)))))))
\ No newline at end of file

Modified: trunk/src/rest_interface/set-up-json-interface.lisp
==============================================================================
--- trunk/src/rest_interface/set-up-json-interface.lisp	(original)
+++ trunk/src/rest_interface/set-up-json-interface.lisp	Sun May 31 09:08:00 2009
@@ -12,7 +12,7 @@
 (defparameter *json-get-prefix* "/json/get/(.+)$") ;the prefix to get a fragment by the psis -> localhost:8000/json/get/<fragment-psi>
 (defparameter *json-commit-url* "/json/commit/?$") ;the url to commit a json fragment by "put" or "post"
 (defparameter *json-get-all-psis* "/json/psis/?$") ;the url to get all topic psis of isidorus -> localhost:8000/json/psis
-(defparameter *json-get-summary-url* "/json/summary/?$") ;the url to get a summary od all topic stored in isidorus; you have to set the GET-parameter "start" for the start index of all topics within elephant and the GET-paramter "end" for the last index of the topic sequence -> http://localhost:8000/json/summary/?start=12&end=13
+(defparameter *json-get-summary-url* "/json/summary/?$") ;the url to get a summary of all topic stored in isidorus; you have to set the GET-parameter "start" for the start index of all topics within elephant and the GET-paramter "end" for the last index of the topic sequence -> http://localhost:8000/json/summary/?start=12&end=13
 (defparameter *json-get-all-type-psis* "/json/tmcl/types/?$") ;returns a list of all psis that can be a type
 (defparameter *json-get-topic-stub-prefix* "/json/topicstubs/(.+)$") ;the json prefix for getting some topic stub information of a topic
 (defparameter *json-get-type-tmcl-url* "/json/tmcl/type/?$") ;the json url for getting some tmcl information of a topic treated as a type

Modified: trunk/src/unit_tests/poems.xtm
==============================================================================
--- trunk/src/unit_tests/poems.xtm	(original)
+++ trunk/src/unit_tests/poems.xtm	Sun May 31 09:08:00 2009
@@ -582,7 +582,7 @@
     <tm:instanceOf><tm:topicRef href="#occurrencetype"/></tm:instanceOf>
   </tm:topic>
 
-  <!-- poem scopes -->
+  <!-- available scopes -->
   <tm:topic id="de">
     <tm:subjectIdentifier href="http://some.where/base-psis/de"/>
     <tm:instanceOf><tm:topicRef href="#scopetype"/></tm:instanceOf>
@@ -593,6 +593,26 @@
     <tm:instanceOf><tm:topicRef href="#scopetype"/></tm:instanceOf>
   </tm:topic>
 
+  <tm:topic id="fr">
+    <tm:subjectIdentifier href="http://some.where/base-psis/fr"/>
+    <tm:instanceOf><tm:topicRef href="#scopetype"/></tm:instanceOf>
+  </tm:topic>
+
+  <tm:topic id="fin">
+    <tm:subjectIdentifier href="http://some.where/base-psis/fin"/>
+    <tm:instanceOf><tm:topicRef href="#scopetype"/></tm:instanceOf>
+  </tm:topic>
+
+  <tm:topic id="rus">
+    <tm:subjectIdentifier href="http://some.where/base-psis/rus"/>
+    <tm:instanceOf><tm:topicRef href="#scopetype"/></tm:instanceOf>
+  </tm:topic>
+
+  <tm:topic id="pl">
+    <tm:subjectIdentifier href="http://some.where/base-psis/pl"/>
+    <tm:instanceOf><tm:topicRef href="#scopetype"/></tm:instanceOf>
+  </tm:topic>
+  
   <!-- region -->
   <tm:topic id="region">
     <tm:subjectIdentifier href="http://some.where/base-psis/region"/>
@@ -1059,7 +1079,7 @@
     </tm:occurrence>
     <tm:occurrence>
       <tm:type><tm:topicRef href="#card-max"/></tm:type>
-      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">3</tm:resourceData>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
     </tm:occurrence>
     <tm:occurrence>
       <tm:type><tm:topicRef href="#regexp"/></tm:type>
@@ -1262,8 +1282,9 @@
   </tm:association>
 
   <!-- country-name scopes -->
-  <tm:topic id="scoped-country-name-constraint">
-    <tm:subjectIdentifier href="http://some.where/constraint-psis/scoped-country-name-constraint"/>
+  <!-- scope constraint 1: there must be either the scope en or de -->
+  <tm:topic id="scoped-country-name-constraint-1">
+    <tm:subjectIdentifier href="http://some.where/constraint-psis/scoped-country-name-constraint-1"/>
     <tm:instanceOf><tm:topicRef href="#nametypescope-constraint"/></tm:instanceOf>
     <tm:occurrence>
       <tm:type><tm:topicRef href="#card-min"/></tm:type>
@@ -1279,7 +1300,7 @@
     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
     <tm:role>
       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
-      <tm:topicRef href="#scoped-country-name-constraint"/>
+      <tm:topicRef href="#scoped-country-name-constraint-1"/>
     </tm:role>
     <tm:role>
       <tm:type><tm:topicRef href="#nametype-role"/></tm:type>
@@ -1291,7 +1312,7 @@
     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
     <tm:role>
       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
-      <tm:topicRef href="#scoped-country-name-constraint"/>
+      <tm:topicRef href="#scoped-country-name-constraint-1"/>
     </tm:role>
     <tm:role>
       <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
@@ -1303,14 +1324,111 @@
     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
     <tm:role>
       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
-      <tm:topicRef href="#scoped-country-name-constraint"/>
+      <tm:topicRef href="#scoped-country-name-constraint-1"/>
     </tm:role>
     <tm:role>
       <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
       <tm:topicRef href="#de"/>
     </tm:role>
   </tm:association>
+  
+  <!-- scope constraint 2: there can exist the scopes de, en, pl, fr, fin or rus -->
+  <tm:topic id="scoped-country-name-constraint-2">
+    <tm:subjectIdentifier href="http://some.where/constraint-psis/scoped-country-name-constraint-2"/>
+    <tm:instanceOf><tm:topicRef href="#nametypescope-constraint"/></tm:instanceOf>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#card-min"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">0</tm:resourceData>
+    </tm:occurrence>
+    <tm:occurrence>
+      <tm:type><tm:topicRef href="#card-max"/></tm:type>
+      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">6</tm:resourceData>
+    </tm:occurrence>
+  </tm:topic>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
+      <tm:topicRef href="#scoped-country-name-constraint-2"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#nametype-role"/></tm:type>
+      <tm:topicRef href="#country-name"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
+      <tm:topicRef href="#scoped-country-name-constraint-2"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
+      <tm:topicRef href="#en"/>
+    </tm:role>
+  </tm:association>
 
+  <tm:association>
+    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
+      <tm:topicRef href="#scoped-country-name-constraint-2"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
+      <tm:topicRef href="#pl"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
+      <tm:topicRef href="#scoped-country-name-constraint-2"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
+      <tm:topicRef href="#fr"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
+      <tm:topicRef href="#scoped-country-name-constraint-2"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
+      <tm:topicRef href="#fin"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
+      <tm:topicRef href="#scoped-country-name-constraint-2"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
+      <tm:topicRef href="#rus"/>
+    </tm:role>
+  </tm:association>
+
+  <tm:association>
+    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
+    <tm:role>
+      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
+      <tm:topicRef href="#scoped-country-name-constraint-2"/>
+    </tm:role>
+    <tm:role>
+      <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
+      <tm:topicRef href="#de"/>
+    </tm:role>
+  </tm:association>
 
   <!-- ===================================================================== -->
   <!-- === own datamodel: occurence constraints ============================ -->

Modified: trunk/src/xml/setup.lisp
==============================================================================
--- trunk/src/xml/setup.lisp	(original)
+++ trunk/src/xml/setup.lisp	Sun May 31 09:08:00 2009
@@ -33,7 +33,10 @@
     (if (eq xtm-format '2.0)
         (importer xtm-dom :tm-id tm-id :xtm-id xtm-id)
         (importer-xtm1.0 xtm-dom :tm-id tm-id :xtm-id xtm-id))
-    (format t "#Topics in the store: ~a~%" (length (elephant:get-instances-by-class 'TopicC)))))
+    (format t "#Objects in the store: Topics: ~a, Associations: ~a~%"
+	    (length (elephant:get-instances-by-class 'TopicC))
+	    (length (elephant:get-instances-by-class 'AssociationC)))))
+    ;(format t "#Topics in the store: ~a~%" (length (elephant:get-instances-by-class 'TopicC)))))
 
 (defun setup-repository (xtm-path repository-path 
                          &key




More information about the Isidorus-cvs mailing list