Index: trunk/zoo-project/zoo-kernel/service.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service.h	(revision 357)
+++ trunk/zoo-project/zoo-kernel/service.h	(revision 360)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2010 GeoLabs SARL
+ * Copyright (c) 2009-2012 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -596,4 +596,97 @@
   }
 
+  static map* getMapArray(map* m,char* key,int index){
+    char tmp[1024];
+    if(index>0)
+      sprintf(tmp,"%s_%d",key,index);
+    else
+      sprintf(tmp,key);
+#ifdef DEBUG
+    fprintf(stderr,"** KEY %s\n",tmp);
+#endif
+    map* tmpMap=getMap(m,tmp);
+#ifdef DEBUG
+    if(tmpMap!=NULL)
+      dumpMap(tmpMap);
+#endif
+    return tmpMap;
+  }
+
+
+  static void setMapArray(map* m,char* key,int index,char* value){
+    char tmp[1024];
+    if(index>0)
+      sprintf(tmp,"%s_%d",key,index);
+    else
+      sprintf(tmp,key);
+    map* tmpSize=getMapArray(m,"size",index);
+    if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){
+      fprintf(stderr,"%s\n",tmpSize->value);
+      map* ptr=getMapOrFill(m,tmp,"");
+      free(ptr->value);
+      ptr->value=(char*)malloc((atoi(tmpSize->value)+1)*sizeof(char));
+      memcpy(ptr->value,value,atoi(tmpSize->value)); 
+    }
+    else
+      addToMap(m,tmp,value);
+  }
+
+  static map* getMapType(map* mt){
+    map* tmap=getMap(mt,"mimeType");
+    if(tmap==NULL){
+      tmap=getMap(mt,"dataType");
+      if(tmap==NULL){
+	tmap=getMap(mt,"CRS");
+      }
+    }
+    dumpMap(tmap);
+    return tmap;
+  }
+
+  static int addMapsArrayToMaps(maps** mo,maps* mi,char* typ){
+    maps* tmp=mi;
+    maps* _cursor=*mo;
+    maps* tmpMaps=getMaps(_cursor,tmp->name);
+
+    if(tmpMaps==NULL)
+      return -1;
+
+    map* tmpLength=getMap(tmpMaps->content,"length");
+    char tmpLen[10];
+    int len=1;
+    if(tmpLength!=NULL){
+      len=atoi(tmpLength->value);
+    }
+
+    map* tmpValI=getMap(tmp->content,"value");
+    char *tmpV[8]={
+      "size",
+      "value",
+      "uom",
+      "Reference",
+      "xlink:href",
+      typ,
+      "schema",
+      "encoding"
+    };
+    sprintf(tmpLen,"%d",len+1);
+    addToMap(_cursor->content,"length",tmpLen);
+    int i=0;
+    map* tmpSizeI=getMap(tmp->content,tmpV[i]);
+    for(0;i<8;i++){
+      map* tmpVI=getMap(tmp->content,tmpV[i]);
+      if(tmpVI!=NULL){
+	fprintf(stderr,"%s = %s\n",tmpV[i],tmpVI->value);
+	if(i<5)
+	  setMapArray(_cursor->content,tmpV[i],len,tmpVI->value);
+	else
+	  if(strncasecmp(tmpV[5],"mimeType",8)==0)
+	    setMapArray(_cursor->content,tmpV[i],len,tmpVI->value);
+      }
+    }
+    
+    addToMap(_cursor->content,"isArray","true");
+    return 0;
+  }
 
   static void setMapInMaps(maps* m,const char* key,const char* subkey,const char *value){
Index: trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.c	(revision 357)
+++ trunk/zoo-project/zoo-kernel/service_internal.c	(revision 360)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2011 GeoLabs SARL
+ * Copyright (c) 2009-2012 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -2188,5 +2188,5 @@
 	map* tmpContent=tmpIoType->content;
 	map* cval=NULL;
-
+	int hasPassed=-1;
 	while(tmpContent!=NULL){
 	  if((cval=getMap(tmpMaps->content,tmpContent->name))==NULL){
@@ -2198,4 +2198,22 @@
 	    else
 	      addToMap(tmpMaps->content,tmpContent->name,tmpContent->value);
+	    
+	    if(hasPassed<0 && type==0 && getMap(tmpMaps->content,"isArray")!=NULL){
+	      map* length=getMap(tmpMaps->content,"length");
+	      int i;
+	      char *tcn=strdup(tmpContent->name);
+	      for(i=1;i<atoi(length->value);i++){
+		dumpMap(tmpMaps->content);
+		fprintf(stderr,"addDefaultValues %s_%d => %s\n",tcn,i,tmpContent->value);
+		int len=strlen(tcn);
+		char *tmp1=malloc((len+10)*sizeof(char));
+		sprintf(tmp1,"%s_%d",tcn,i);
+		fprintf(stderr,"addDefaultValues %s => %s\n",tmp1,tmpContent->value);
+		addToMap(tmpMaps->content,tmp1,tmpContent->value);
+		free(tmp1);
+		hasPassed=1;
+	      }
+	      free(tcn);
+	    }
 	  }
 	  tmpContent=tmpContent->next;
@@ -2484,8 +2502,11 @@
     return errorException(m, _("Unable to download the file."), "InternalError");
   }
+
   map* tmpMap=getMapOrFill(content,"value","");
+    
   free(tmpMap->value);
   tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
-  memcpy(tmpMap->value,fcontent,(fsize)*sizeof(char)); 
+  memcpy(tmpMap->value,fcontent,(fsize)*sizeof(char));
+
   char ltmp1[256];
   sprintf(ltmp1,"%d",fsize);
Index: trunk/zoo-project/zoo-kernel/service_internal_java.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 357)
+++ trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 360)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2011 GeoLabs SARL
+ * Copyright (c) 2009-2012 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -201,13 +201,61 @@
     maps* tmp=t;
     while(tmp!=NULL){
+      map* tmap=getMapType(tmp->content);
       map* tmp1=tmp->content;
       scObject1 = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
       map* sizeV=getMap(tmp1,"size");
+      map* isArray=getMap(tmp1,"isArray");
+      map* alen=getMap(tmp1,"length");
       while(tmp1!=NULL){
-	if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){
-	  jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value));
-	  (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),tmp1->value);
-	  (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), tmpData);
-	}else
+	if(strcmp(tmp1->name,"value")==0){
+	  if(isArray==NULL){
+	    if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){
+	      jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value));
+	      (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),tmp1->value);
+	      (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), tmpData);
+	    }else
+	      (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
+	  }
+	  else{
+	    int alen1=atoi(alen->value);
+	    fprintf(stderr,"LENGTH %d \n",alen1);
+	    
+	    jclass scArrayListClass,scArrayList_class;
+	    jmethodID scArrayList_constructor;
+	    jobject scObject2,scObject3,scObject4;
+	    scArrayListClass = (*env)->FindClass(env, "java/util/ArrayList");
+	    scArrayList_class = (*env)->NewGlobalRef(env, scArrayListClass);
+	    scArrayList_constructor = (*env)->GetMethodID(env, scArrayList_class, "<init>", "()V");
+	    jmethodID add_mid = 0;
+	    scObject2 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
+	    scObject3 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
+	    scObject4 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
+
+	    add_mid = (*env)->GetMethodID(env,scArrayListClass,
+					  "add","(Ljava/lang/Object;)Z");
+	    
+	    int i;
+	    
+	    for(i=0;i<alen1;i++){
+	      map* vMap=getMapArray(tmp->content,"value",i);	    
+	      map* sMap=getMapArray(tmp->content,"size",i);
+	      map* mMap=getMapArray(tmp->content,tmap->value,i);
+	      
+	      if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0){
+		jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sMap->value));
+		(*env)->SetByteArrayRegion(env,tmpData,0,atoi(sMap->value),vMap->value);
+		(*env)->CallObjectMethod(env,scObject2, add_mid, tmpData);
+	      }else{
+		jobject tmpData=(*env)->NewStringUTF(env,vMap->value);
+		(*env)->CallObjectMethod(env,scObject2, add_mid, tmpData);
+	      }
+	      
+	    }
+	    
+	    (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), scObject2);
+	    
+	  }
+	}
+	else
 	  (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
 	tmp1=tmp1->next;
Index: trunk/zoo-project/zoo-kernel/service_internal_js.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 357)
+++ trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 360)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2010 GeoLabs SARL
+ * Copyright (c) 2009-2012 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -352,11 +352,50 @@
   jsval resf =  OBJECT_TO_JSVAL(res);
   map* tmpm=t;
+  map* isArray=getMap(t,"isArray");
+  map* isBinary=getMap(t,"size");
+  map* tmap=getMapType(t);
+  if(tmap==NULL)
+    fprintf(stderr,"tmap is null !\n");
+  else
+    fprintf(stderr,"tmap is not null ! (%s = %s)\n",tmap->name,tmap->value);
+
+  /* Avoid gesture of binary content which failed due to strlen function use */
+  if(isBinary!=NULL){
+    return res;
+  }
   while(tmpm!=NULL){
-    jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm->value,strlen(tmpm->value)));
-    JS_SetProperty(cx, res, tmpm->name,&jsstr);
-#ifdef JS_DEBUG
-    fprintf(stderr,"%s => %s\n",tmpm->name,tmpm->value);
-#endif
+    if(isArray==NULL || strncasecmp(tmpm->name,"value",5)!=0 || 
+       (tmap!=NULL && strncasecmp(tmpm->name,tmap->name,strlen(tmap->name))!=0)){
+      jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm->value,strlen(tmpm->value)));
+      JS_SetProperty(cx, res, tmpm->name,&jsstr);
+#ifdef JS_DEBUG
+      fprintf(stderr,"%s => %s\n",tmpm->name,tmpm->value);
+#endif
+    }
     tmpm=tmpm->next;
+  }
+  if(isArray!=NULL){
+    map* len=getMap(t,"length");
+    int cnt=atoi(len->value);
+    JSObject* values=JS_NewArrayObject( cx, cnt, NULL );
+    JSObject* mvalues=JS_NewArrayObject( cx, cnt, NULL );
+    map *tmpm1,*tmpm2;
+    int i=0;
+    for(i=0;i<cnt;i++){
+      tmpm1=getMapArray(t,"value",i);
+      tmpm2=getMapArray(t,tmap->name,i);
+      if(tmpm1!=NULL){
+	jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm1->value,strlen(tmpm1->value)));
+	JS_SetElement( cx, values, i, &jsstr );
+      }
+      if(tmpm2!=NULL){
+	jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm2->value,strlen(tmpm2->value)));
+	JS_SetElement( cx, mvalues, i, &jsstr );
+      }
+    }
+    jsval jvalues=OBJECT_TO_JSVAL(values);
+    jsval jmvalues=OBJECT_TO_JSVAL(mvalues);
+    JS_SetProperty(cx, res,"value",&jvalues);
+    JS_SetProperty(cx, res,tmap->name,&jmvalues);
   }
   return res;
Index: trunk/zoo-project/zoo-kernel/service_internal_ms.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 357)
+++ trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 360)
@@ -126,7 +126,4 @@
 
   if(proto>0){
-    map* test=getMap(tmpI->content,"real_extent");
-    if(test!=NULL)
-	extent=test;
     sprintf(webService_url,
 	    "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
@@ -145,7 +142,4 @@
   }
   else{
-    map* test=getMap(tmpI->content,"real_extent_reverse");
-    if(test!=NULL)
-	extent=test;
     sprintf(webService_url,
 	    "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s",
@@ -281,9 +275,10 @@
   
   if(output!=NULL){
+
     map* test=getMap(output->content,"real_extent");
     if(test!=NULL){
       pointObj min, max;
       projectionObj tempSrs;
-      
+
       min.x = m->extent.minx;
       min.y = m->extent.miny;
@@ -291,16 +286,22 @@
       max.y = m->extent.maxy;
       char tmpSrsStr[1024];
-      
+
+
       msInitProjection(&tempSrs);
       msLoadProjectionStringEPSG(&tempSrs,"EPSG:4326");
-      
+
       msProjectPoint(&(m->projection),&tempSrs,&min);
       msProjectPoint(&m->projection,&tempSrs,&max);
       
       sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.y,min.x,max.y,max.x);
+      map* isGeo=getMap(output->content,"crs_isGeographic");
+      fprintf(stderr,"isGeo = %s\n",isGeo->value);
+      if(isGeo!=NULL && strcasecmp("true",isGeo->value)==0)
+        sprintf(tmpExtent,"%f,%f,%f,%f", minY,minX, maxY, maxX);
       addToMap(output->content,"wms_extent",tmpExtent);
-      sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y);
+      sprintf(tmpSrsStr,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y);
       addToMap(output->content,"wcs_extent",tmpExtent);
-      
+      dumpMap(output->content);
+
     }else{
       sprintf(tmpExtent,"%f,%f,%f,%f",minX, minY, maxX, maxY);
@@ -308,9 +309,11 @@
       fprintf(stderr,"isGeo = %s\n",isGeo->value);
       if(isGeo!=NULL && strcasecmp("true",isGeo->value)==0)
-	sprintf(tmpExtent,"%f,%f,%f,%f", minY,minX, maxY, maxX);
+        sprintf(tmpExtent,"%f,%f,%f,%f", minY,minX, maxY, maxX);
       addToMap(output->content,"wms_extent",tmpExtent); 
       sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",minX,minY,maxX,maxY);
-      addToMap(output->content,"wcs_extent",tmpExtent); 
-    }
+      addToMap(output->content,"wcs_extent",tmpExtent);
+      
+    }
+
   }
 
@@ -858,8 +861,14 @@
    * Firs store the value on disk
    */
+  map* mime=getMap(outputs->content,"mimeType");
+  char *ext="data";
+  if(mime!=NULL)
+    if(strncasecmp(mime->value,"application/json",16)==0)
+      ext="json";
+  
   map* tmpMap=getMapFromMaps(conf,"main","dataPath");
   map* sidMap=getMapFromMaps(conf,"lenv","sid");
   char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char));
-  sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.data",tmpMap->value,outputs->name,sidMap->value);
+  sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext);
   int f=open(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
   map* sizeMap=getMap(outputs->content,"size");
Index: trunk/zoo-project/zoo-kernel/service_internal_python.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 357)
+++ trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 360)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2011 GeoLabs SARL
+ * Copyright (c) 2009-2012 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -208,9 +208,76 @@
   PyObject* res=PyDict_New( );
   map* tmp=t;
+  int hasSize=0;
+  map* isArray=getMap(tmp,"isArray");
   map* size=getMap(tmp,"size");
+  map* tmap=getMapType(tmp);
   while(tmp!=NULL){
     PyObject* name=PyString_FromString(tmp->name);
-    if(strcasecmp(tmp->name,"value")==0){
-      if(size!=NULL){
+    if(strcasecmp(tmp->name,"value")==0) {
+      if(isArray!=NULL){
+	map* len=getMap(tmp,"length");
+	int cnt=atoi(len->value);
+	PyObject* value=PyList_New(cnt);
+	PyObject* mvalue=PyList_New(cnt);
+	PyObject* svalue=PyList_New(cnt);
+
+	for(int i=0;i<cnt;i++){
+	  
+	  map* vMap=getMapArray(tmp,"value",i);	    
+	  map* sMap=getMapArray(tmp,"size",i);
+
+	  if(vMap!=NULL){
+	    
+	    PyObject* lvalue;
+	    PyObject* lsvalue;
+	    if(sMap==NULL){
+	      lvalue=PyString_FromString(vMap->value);
+	      lsvalue=Py_None;
+	    }
+	    else{
+	      lvalue=PyString_FromStringAndSize(vMap->value,atoi(sMap->value));
+	      lsvalue=PyString_FromString(sMap->value);
+	      hasSize=1;
+	    }
+
+	    if(PyList_SetItem(value,i,lvalue)<0){
+	      fprintf(stderr,"Unable to set key value pair...");
+	      return NULL;
+	    } 
+	    if(PyList_SetItem(svalue,i,lsvalue)<0){
+	      fprintf(stderr,"Unable to set key value pair...");
+	      return NULL;
+	    } 
+	  }
+	  
+	  map* mMap=getMapArray(tmp,tmap->name,i);
+	  PyObject* lmvalue;
+	  if(mMap!=NULL){
+	    lmvalue=PyString_FromString(mMap->value);
+	  }else
+	    lmvalue=Py_None;
+	  
+	  if(PyList_SetItem(mvalue,i,lmvalue)<0){
+	      fprintf(stderr,"Unable to set key value pair...");
+	      return NULL;
+	  } 
+	  
+	}
+
+	if(PyDict_SetItem(res,name,value)<0){
+	  fprintf(stderr,"Unable to set key value pair...");
+	  return NULL;
+	}
+	if(PyDict_SetItem(res,PyString_FromString(tmap->name),mvalue)<0){
+	  fprintf(stderr,"Unable to set key value pair...");
+	  return NULL;
+	}
+	if(hasSize>0)
+	  if(PyDict_SetItem(res,PyString_FromString("size"),svalue)<0){
+	    fprintf(stderr,"Unable to set key value pair...");
+	    return NULL;
+	  }
+      }
+      else if(size!=NULL){
 	PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value));
 	if(PyDict_SetItem(res,name,value)<0){
@@ -228,8 +295,10 @@
     }
     else{
-      PyObject* value=PyString_FromString(tmp->value);
-      if(PyDict_SetItem(res,name,value)<0){
-	fprintf(stderr,"Unable to set key value pair...");
-	return NULL;
+      if(PyDict_GetItem(res,name)==NULL){
+	PyObject* value=PyString_FromString(tmp->value);
+	if(PyDict_SetItem(res,name,value)<0){
+	  fprintf(stderr,"Unable to set key value pair...");
+	  return NULL;
+	}
       }
     }
Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 357)
+++ trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 360)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- *  Copyright 2008-2011 GeoLabs SARL. All rights reserved.
+ *  Copyright 2008-2012 GeoLabs SARL. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -92,4 +92,45 @@
       str[i]=toReplaceBy;
   }
+}
+
+/**
+ * Create (or append to) an array valued maps
+ * value = "["",""]"
+ */
+int appendMapsToMaps(maps* m,maps* mo,maps* mi,elements* elem){
+
+  map* tmap=getMapType(mo->content);
+  if(tmap==NULL){
+    tmap=getMapType(elem->defaults->content);
+  }
+
+  map* testMap=getMap(elem->content,"maxOccurs");
+  if(testMap!=NULL){
+    if(strncasecmp(testMap->value,"unbounded",9)!=0 && atoi(testMap->value)>1){
+      if(addMapsArrayToMaps(&mo,mi,tmap->name)<0){
+	char emsg[1024];
+	sprintf(emsg,_("You set maximum occurences for <%s> as %i but you tried to use it more than the limit you set. Please correct your ZCFG file or your request."),mi->name,atoi(testMap->value));
+	errorException(m,emsg,"InternalError");
+	return -1;
+      }
+    }else{
+      if(strncasecmp(testMap->value,"unbounded",9)==0){
+	if(addMapsArrayToMaps(&mo,mi,tmap->name)<0){
+	  char emsg[1024];
+	  map* tmpMap=getMap(mi->content,"length");
+	  sprintf(emsg,_("ZOO-Kernel was unable to load your data for %s position %s."),mi->name,tmpMap->value);
+	  errorException(m,emsg,"InternalError");
+	  return -1;
+	}
+      }
+      else{
+	char emsg[1024];
+	sprintf(emsg,_("You set maximum occurences for <%s> to one but you tried to use it more than once. Please correct your ZCFG file or your request."),mi->name);
+	errorException(m,emsg,"InternalError");
+	return -1;
+      }
+    }
+  }
+  return 0;
 }
 
@@ -1068,6 +1109,24 @@
 	if(request_input_real_format==NULL)
 	  request_input_real_format=dupMaps(&tmpmaps);
-	else
-	  addMapsToMaps(&request_input_real_format,tmpmaps);
+	else{
+	  maps* testPresence=getMaps(request_input_real_format,tmpmaps->name);
+	  if(testPresence!=NULL){
+	    elements* elem=getElements(s1->inputs,tmpmaps->name);
+	    if(elem!=NULL){
+	      if(appendMapsToMaps(m,request_input_real_format,tmpmaps,elem)<0){
+		freeMaps(&m);
+		free(m);
+		free(REQUEST);
+		free(SERVICE_URL);
+		InternetCloseHandle(hInternet);
+		freeService(&s1);
+		free(s1);
+		return 0;
+	      }
+	    }
+	  }
+	  else
+	    addMapsToMaps(&request_input_real_format,tmpmaps);
+	}
 	freeMaps(&tmpmaps);
 	free(tmpmaps);
@@ -1479,5 +1538,25 @@
 	fflush(stderr);
 #endif
-	addMapsToMaps(&request_input_real_format,tmpmaps);
+
+	{
+	  maps* testPresence=getMaps(request_input_real_format,tmpmaps->name);
+	  if(testPresence!=NULL){
+	    elements* elem=getElements(s1->inputs,tmpmaps->name);
+	    if(elem!=NULL){
+	      if(appendMapsToMaps(m,request_input_real_format,tmpmaps,elem)<0){
+		freeMaps(&m);
+		free(m);
+		free(REQUEST);
+		free(SERVICE_URL);
+		InternetCloseHandle(hInternet);
+		freeService(&s1);
+		free(s1);
+		return 0;
+	      }
+	    }
+	  }
+	  else
+	    addMapsToMaps(&request_input_real_format,tmpmaps);
+	}
 	
 #ifdef DEBUG
