Index: trunk/zoo-project/zoo-kernel/service_conf.y
===================================================================
--- trunk/zoo-project/zoo-kernel/service_conf.y	(revision 618)
+++ trunk/zoo-project/zoo-kernel/service_conf.y	(revision 621)
@@ -1,7 +1,24 @@
 /*
- * Thx to Jean-Marie CODOL and Naitan GROLLEMUND
- * copyright 2009 GeoLabs SARL 
  * Author : Gérald FENOY
  *
+ * Copyright (c) 209-2015 GeoLabs SARL
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
  */
 %{
@@ -64,11 +81,5 @@
 %token <s> ID
 %token <s> CHAINE
-/* STARTXMLDECL et ENDXMLDECL qui sont <?xml et ?>*/
-%token STARTXMLDECL ENDXMLDECL
-
-/* version="xxx" et encoding="xxx" */
-%token VERSIONDECL ENCODINGDECL SDDECL
-
-/* < et > */
+
 %token INFCAR SUPCAR 
 
@@ -130,5 +141,5 @@
 {
 #ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"(%s %d) %s\n",__FILE__,__LINE__,$2);
+  fprintf(stderr,"STag (%s %d) %s %d %d \n",__FILE__,__LINE__,$2,current_data,previous_data);
   fflush(stderr);
   dumpMap(current_content);
@@ -146,11 +157,4 @@
   }
   if(strncasecmp($2,"DataInputs",10)==0){
-    if(wait_mainmetadata==true && current_content!=NULL){
-      addMapToMap(&my_service->metadata,current_content);
-      freeMap(&current_content);
-      free(current_content);
-      current_content=NULL;
-      wait_mainmetadata=false;
-    }
     if(current_element==NULL){
 #ifdef DEBUG_SERVICE_CONF
@@ -255,34 +259,13 @@
 	   || strncasecmp($2,"BoundingBoxOutput",13)==0 || strncasecmp($2,"BoundingBoxData",12)==0){
 	  current_data=4;
-	  if(wait_metadata==true){
-	    if(current_content!=NULL){
-#ifdef DEBUG_SERVICE_CONF
-	      fprintf(stderr,"add current_content to current_element->content\n");
-	      fprintf(stderr,"LINE %d",__LINE__);
-#endif
-	      addMapToMap(&current_element->metadata,current_content);
-	      current_element->next=NULL;
-	      if($2!=NULL)
-		current_element->format=zStrdup($2);
-	      
-	      current_element->defaults=NULL;
-	      current_element->supported=NULL;
-	      freeMap(&current_content);
-	      free(current_content);
-	    }
-	  }else{ 
-	    // No MainMetaData
-	    addMapToMap(&current_element->content,current_content);
-	    freeMap(&current_content);
-	    free(current_content);
-	    current_element->metadata=NULL;
-	    current_element->next=NULL;
-	    if($2!=NULL)
-	      current_element->format=zStrdup($2);
-	    current_element->defaults=NULL;
-	    current_element->supported=NULL;
-	  }
+	  addMapToMap(&current_element->content,current_content);
+	  freeMap(&current_content);
+	  free(current_content);
+	  current_element->next=NULL;
+	  if($2!=NULL)
+	    current_element->format=zStrdup($2);
+	  current_element->defaults=NULL;
+	  current_element->supported=NULL;
 	  current_content=NULL;
-	  wait_metadata=false;
 	}
 	else
@@ -311,5 +294,5 @@
 // utiliser la récursivité a gauche
 Attributeetoile
- : Attributeetoile attribute  {}
+: Attributeetoile attribute  {}
  | 	                          {/* Epsilon */}
  ;
@@ -367,5 +350,5 @@
 {
 #ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
+  fprintf(stderr,"ETag %s (%s %d) %d %d \n",$3,__FILE__,__LINE__,current_data,previous_data);
 #endif
   if(strcmp($3,"DataInputs")==0){
@@ -399,8 +382,33 @@
   }
   if(strcmp($3,"MetaData")==0){
+    if(current_content!=NULL){
+#ifdef DEBUG_SERVICE_CONF
+      fprintf(stderr,"add current_content to current_element->content\n");
+      fprintf(stderr,"LINE %d",__LINE__);
+#endif
+      if(wait_metadata){
+	current_element->metadata=NULL;
+	addMapToMap(&current_element->metadata,current_content);
+	current_element->next=NULL;
+	current_element->defaults=NULL;
+	current_element->supported=NULL;
+      }else{
+	if(wait_mainmetadata){
+	  addMapToMap(&my_service->metadata,current_content);
+	}
+      }
+
+      freeMap(&current_content);
+      free(current_content);
+      current_content=NULL;
+    }
     current_data=previous_data;
+    wait_mainmetadata=false;
+    wait_metadata=false;
   }
   if(strcmp($3,"ComplexData")==0 || strcmp($3,"LiteralData")==0 
      || strcmp($3,"ComplexOutput")==0 || strcmp($3,"LiteralOutput")==0){
+    if(current_element->format==NULL)
+      current_element->format=zStrdup($3);
     current_content=NULL;
   }
@@ -497,6 +505,31 @@
 | EPAIR {
 #ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
-  fprintf(stderr,"EPAIR FOUND !! \n"); 
+  fprintf(stderr,"EPAIR (%s %d)\n",__FILE__,__LINE__);
+  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
+  dumpMap(current_content);
+  fflush(stderr);
+#endif
+  if($1!=NULL && curr_key!=NULL){
+    if(current_content==NULL){
+#ifdef DEBUG_SERVICE_CONF
+      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
+#endif
+      current_content=createMap(curr_key,$1);
+#ifdef DEBUG_SERVICE_CONF
+      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
+#endif
+    }
+    else{ 
+#ifdef DEBUG_SERVICE_CONF
+      dumpMap(current_content);
+      fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1); 
+#endif
+      addToMap(current_content,curr_key,$1);
+#ifdef DEBUG_SERVICE_CONF
+      fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1); 
+#endif    
+    }
+  }
+#ifdef DEBUG_SERVICE_CONF
   fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
   fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
@@ -504,31 +537,4 @@
   fflush(stderr);
 #endif
-  if($1!=NULL && curr_key!=NULL){
-    if(current_content==NULL){
-#ifdef DEBUG_SERVICE_CONF
-      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
-#endif
-      current_content=createMap(curr_key,$1);
-#ifdef DEBUG_SERVICE_CONF
-      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
-#endif
-    }
-    else{ 
-#ifdef DEBUG_SERVICE_CONF
-      dumpMap(current_content);
-      fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1); 
-#endif
-      addToMap(current_content,curr_key,$1);
-#ifdef DEBUG_SERVICE_CONF
-      fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1); 
-#endif    
-    }
-  }
-#ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
-  fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
-  dumpMap(current_content);
-  fflush(stderr);
-#endif
   if(curr_key!=NULL){
     free(curr_key);
@@ -543,5 +549,5 @@
 : ANID  {
 #ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
+  fprintf(stderr,"processid (%s %d) %s\n",__FILE__,__LINE__,$1);
 #endif
   if(data==-1){
