Index: XIOS2/trunk/src/group_template.hpp
===================================================================
--- XIOS2/trunk/src/group_template.hpp	(revision 2610)
+++ XIOS2/trunk/src/group_template.hpp	(revision 2615)
@@ -51,4 +51,6 @@
          virtual void parse(xml::CXMLNode & node);
          virtual void parse(xml::CXMLNode & node, bool withAttr);
+         virtual void parse(xml::CXMLNode & node, bool withAttr, const std::set<StdString>& parseContextList);
+         
          virtual void parseChild(xml::CXMLNode & node);
         
Index: XIOS2/trunk/src/group_template_impl.hpp
===================================================================
--- XIOS2/trunk/src/group_template_impl.hpp	(revision 2610)
+++ XIOS2/trunk/src/group_template_impl.hpp	(revision 2615)
@@ -252,11 +252,4 @@
    }
 
-   //---------------------------------------------------------------
-
-   template <class U, class V, class W>
-      void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node)
-   { 
-      this->parse(node, true); 
-   }
    
    //---------------------------------------------------------------
@@ -511,4 +504,19 @@
    }
 
+  //---------------------------------------------------------------
+
+   template <class U, class V, class W>
+      void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node)
+   { 
+      this->parse(node, true); 
+   }
+   
+   template <class U, class V, class W>
+   void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr, const std::set<StdString>& parseContextList)
+   {
+     ERROR("void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr, const std::set<StdString>& parseContextList)",
+                     <<"must not be called by this kind of object : "<<GetName() ) ;
+   }
+
    template <class U, class V, class W>
       void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)
@@ -520,16 +528,5 @@
       {
          CGroupTemplate<U, V, W>::SuperClass::parse(node);
-         if (attributes.end() != attributes.find("src"))
-         {
-            StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in );
-            if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 )
-               ERROR("void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)",
-                     <<endl<< "Can not open <"<<attributes["src"].c_str()<<"> file" );
-            
-            if (!ifs.good())
-               ERROR("CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)",
-                     << "[ filename = " << attributes["src"] << " ] Bad xml stream !");
-            xml::CXMLParser::ParseInclude(ifs, attributes["src"].c_str(), *this);
-         }
+         if (attributes.end() != attributes.find("src")) xml::CXMLParser::ParseInclude(attributes["src"].c_str(), *this);
       }
 
Index: XIOS2/trunk/src/node/context.cpp
===================================================================
--- XIOS2/trunk/src/node/context.cpp	(revision 2610)
+++ XIOS2/trunk/src/node/context.cpp	(revision 2615)
@@ -113,15 +113,5 @@
       xml::THashAttributes attributes = node.getAttributes();
 
-      if (attributes.end() != attributes.find("src"))
-      {
-         StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in );
-         if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 )
-            ERROR("void CContext::parse(xml::CXMLNode & node)",
-                  <<endl<< "Can not open <"<<attributes["src"].c_str()<<"> file" );
-         if (!ifs.good())
-            ERROR("CContext::parse(xml::CXMLNode & node)",
-                  << "[ filename = " << attributes["src"] << " ] Bad xml stream !");
-         xml::CXMLParser::ParseInclude(ifs, attributes["src"], *this);
-      }
+      if (attributes.end() != attributes.find("src")) xml::CXMLParser::ParseInclude(attributes["src"], *this);
 
       if (node.getElementName().compare(CContext::GetName()))
@@ -162,4 +152,68 @@
    }
    CATCH_DUMP_ATTR
+
+   template <>
+   void CGroupTemplate<CContext, CContextGroup, CContextAttributes>::parse(xml::CXMLNode & node, bool withAttr, const std::set<StdString>& parseContextList)
+   TRY
+   {
+      StdString name = node.getElementName();
+      xml::THashAttributes attributes = node.getAttributes();
+      CGroupTemplate<CContext, CContextGroup, CContextAttributes>::SuperClass::parse(node);
+      if (attributes.end() != attributes.find("src")) xml::CXMLParser::ParseInclude(attributes["src"].c_str(), *this, parseContextList);
+
+      if (!(node.goToChildElement()))
+      {
+        // no children ?
+      }
+      else
+      {
+        do // Parcours pour traitement.
+        { 
+
+          StdString name = node.getElementName();
+          attributes.clear();
+          attributes = node.getAttributes();
+
+          if (name.compare(CContextGroup::GetName()) == 0)
+          {
+            CContextGroup contextGroup ;
+            contextGroup.parse(node, true, parseContextList) ;
+            continue;
+          }
+
+          if (name.compare(CContext::GetName()) == 0)
+          {
+            if (attributes.end() == attributes.find("id"))
+            {
+              DEBUG("The context will not be processed because it is not identified (missing id)");
+              continue;
+            }
+            else
+            {  
+              if (parseContextList.empty() || parseContextList.count(attributes["id"]) > 0)
+              {
+                CContext::setCurrent(attributes["id"]) ;
+                CContext* context = CContext::create(attributes["id"]);
+                context->parse(node);
+                attributes.clear();
+              }
+              continue;
+            }
+          }
+
+          DEBUG(<< "Dans le contexte \'" << CContext::getCurrent()->getId()
+                << "\', un objet de type \'" << CContextGroup::GetName()
+                << "\' ne peut contenir qu'un objet de type \'" << CContextGroup::GetName()
+                << "\' ou de type \'" << CContext::GetName()
+                << "\' (reÃ§u : " << name << ") !");
+
+         } while (node.goToNextElement());
+         node.goToParentElement(); // Retour au parent
+      }
+   }
+   CATCH_DUMP_ATTR
+
+
+
 
    //----------------------------------------------------------------
Index: XIOS2/trunk/src/node/context.hpp
===================================================================
--- XIOS2/trunk/src/node/context.hpp	(revision 2610)
+++ XIOS2/trunk/src/node/context.hpp	(revision 2615)
@@ -274,4 +274,6 @@
    // Declare/Define CContextGroup and CContextDefinition
    DECLARE_GROUP(CContext);
+   template <>
+      void CGroupTemplate<CContext, CContextGroup, CContextAttributes>::parse(xml::CXMLNode & node, bool withAttr, const std::set<StdString>& parseContextList) ;
 
    ///--------------------------------------------------------------
Index: XIOS2/trunk/src/string_tools.hpp
===================================================================
--- XIOS2/trunk/src/string_tools.hpp	(revision 2610)
+++ XIOS2/trunk/src/string_tools.hpp	(revision 2615)
@@ -9,4 +9,5 @@
 {
   std::vector<std::string> splitRegex(const std::string& input, const std::string& regex) ;
+  string strTrim(const std::string& input) ;
 
   inline std::vector<std::string> splitRegex(const std::string& input, const std::string& regex)
@@ -20,4 +21,9 @@
   }
 
+  inline string strTrim(const std::string& input)
+  {
+    return std::regex_replace(input, std::regex("^ +| +$"), "$1");
+  }
+
 }
 #endif
Index: XIOS2/trunk/src/xml_parser.cpp
===================================================================
--- XIOS2/trunk/src/xml_parser.cpp	(revision 2610)
+++ XIOS2/trunk/src/xml_parser.cpp	(revision 2615)
@@ -6,4 +6,5 @@
 #include "object_template.hpp"
 #include "group_template.hpp"
+#include "string_tools.hpp"
 
 namespace xios
@@ -11,4 +12,37 @@
    namespace xml
    {
+      
+      string CXMLParser::currentIncludePath_="." ;
+
+      string CXMLParser::updateIncludePath(const string& filePath)
+      {
+        string path = strTrim(filePath) ;
+        vector<string> match=splitRegex(path+'/',"/" ) ;
+
+        // check if empty path
+        bool isEmpty=true ;
+        for(auto& m : match) 
+          if (!m.empty())
+          {
+            isEmpty=false ;
+            break ;
+          }
+
+        if (isEmpty) ERROR("string CXMLParser::updatePath(const string& filePath)",
+                     << "File path to include an new XML is empty :'"<<filePath<<"'" );
+
+        if (match.back().empty()) ERROR("string CXMLParser::updatePath(const string& filePath)",
+                     << "File path to include an new XML must not be a directory but a file :'"<<filePath<<"'" );
+        bool isAbsolutePath = match.front().empty() ;
+        
+        if (isAbsolutePath) currentIncludePath_="" ;
+        for(int i=0; i<match.size()-1; ++i) if (! match[i].empty()) currentIncludePath_ = currentIncludePath_ + "/" + match[i] ;
+        
+        string finalPath = currentIncludePath_ + "/" + match.back() ;
+
+        return finalPath ;
+      }
+
+
       /// ////////////////////// DÃ©finitions ////////////////////// ///
 
@@ -52,46 +86,8 @@
                      << "Root element should be named simulation (actual = \'"
                      << node.getElementName() << "\')!");
-
-            std::set<StdString>::iterator it;
-            std::set<StdString>::const_iterator itE = parseContextList.end();
-            bool isParseAll = (parseContextList.empty());
             try
             {
-              if (node.goToChildElement())
-              {
-                 do
-                 {
-                    CContextGroup* group_context = CContext::getRoot() ;
-
-                    attributes = node.getAttributes();
-
-                    if (attributes.end() == attributes.find("id"))
-                    {
-                       DEBUG("The context will not be processed because it is not identified (missing id)");
-                       continue;
-                    }
-
-                    CContext::setCurrent(attributes["id"]) ;
-
-                    if (isParseAll)
-                    {
-                      CContext* context = CContext::create(attributes["id"]);
-                      context->parse(node);
-
-                      attributes.clear();
-                    }
-                    else
-                    {
-                      it = parseContextList.find(attributes["id"]);
-                      if (itE != it)
-                      {
-                        CContext* context = CContext::create(*it);
-                        context->parse(node);
-
-                        attributes.clear();
-                      }
-                    }
-                 } while (node.goToNextElement());
-              }
+              CContextGroup* rootContext = CContext::getRoot() ;
+              rootContext->parse(node, true, parseContextList) ;
             }
             catch(CException& e)
Index: XIOS2/trunk/src/xml_parser.hpp
===================================================================
--- XIOS2/trunk/src/xml_parser.hpp	(revision 2610)
+++ XIOS2/trunk/src/xml_parser.hpp	(revision 2615)
@@ -21,30 +21,16 @@
             static void ParseString(const StdString & xmlContent);
             static void ParseStream(StdIStream & stream, const string& fluxId, const std::set<StdString>& parseList);
+            
             template <class T>
-               static void ParseInclude(StdIStream & stream, const string& fluxId, T & object);
+            static void ParseInclude(const string& fluxId, T & object);
+            
+            template <class T>
+            static void ParseInclude(const string& fluxId, T & object, const std::set<StdString>& parseContextList);
+            
+            static string updateIncludePath(const string& filePath) ;
 
+         private:
+            static string currentIncludePath_ ; // current include path for XML file
       }; //class CXMLParser
-/*
-      template <class T>
-         void CXMLParser::ParseInclude(StdIStream & stream, T& object)
-      {
-         StdOStringStream oss;
-         while(!stream.eof() && !stream.fail ())
-            oss.put(stream.get());
-         try
-         {
-            const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 );
-            rapidxml::xml_document<char> doc;
-            doc.parse<0>(const_cast<char*>(xmlcontent.c_str()));
-            CXMLNode node(doc.first_node());
-            object.parse(node);
-         }
-         catch (rapidxml::parse_error & exc)
-         {
-            ERROR("CXMLParser::ParseStream(StdIStream & stream)",
-                  << "RapidXML error : " << exc.what() << " !");
-         }
-      }
-*/
    }// namespace xml
 } // namespace xios
Index: XIOS2/trunk/src/xml_parser_decl.cpp
===================================================================
--- XIOS2/trunk/src/xml_parser_decl.cpp	(revision 2610)
+++ XIOS2/trunk/src/xml_parser_decl.cpp	(revision 2615)
@@ -7,9 +7,8 @@
   namespace xml
   {
-    template void CXMLParser::ParseInclude<CContext>(StdIStream & stream, const string& fluxId, CContext& object) ;
+    template void CXMLParser::ParseInclude<CContext>(const string& fluxId, CContext& object) ;
 
  #   define macro(T) \
-    template void CXMLParser::ParseInclude< CGroupTemplate<C##T, C##T##Group, C##T##Attributes> >(StdIStream & stream, const string& fluxId, CGroupTemplate<C##T, C##T##Group, C##T##Attributes>& object) ;
-
+    template void CXMLParser::ParseInclude< CGroupTemplate<C##T, C##T##Group, C##T##Attributes> >(const string& fluxId, CGroupTemplate<C##T, C##T##Group, C##T##Attributes>& object) ;
     macro( Context )
     macro( Axis )
@@ -40,4 +39,10 @@
     macro( ReorderDomain )
     macro( ExtractDomain )
+
+#   undef macro
+#   define macro(T) \
+    template void CXMLParser::ParseInclude< CGroupTemplate<C##T, C##T##Group, C##T##Attributes> >(const string& fluxId, CGroupTemplate<C##T, C##T##Group, C##T##Attributes>& object, const std::set<StdString>& parseContextList) ;
+    macro( Context )
+#   undef macro
   }
 }
Index: XIOS2/trunk/src/xml_parser_impl.hpp
===================================================================
--- XIOS2/trunk/src/xml_parser_impl.hpp	(revision 2610)
+++ XIOS2/trunk/src/xml_parser_impl.hpp	(revision 2615)
@@ -9,6 +9,18 @@
    namespace xml
    {
-     template <class T> void CXMLParser::ParseInclude(StdIStream & stream, const string& fluxId,  T& object)
+      template <class T> void CXMLParser::ParseInclude(const string& fluxId,  T& object)
       {
+         string parentPath = currentIncludePath_ ;        
+         string filePath = updateIncludePath(fluxId) ;
+
+         StdIFStream stream(filePath, StdIFStream::in ) ;
+         if ( (stream.rdstate() & std::ifstream::failbit ) != 0 )
+               ERROR("template <class T> void CXMLParser::ParseInclude(const string& fluxId,  T& object)",
+                     <<endl<< "Can not open <"<<fluxId<<"> file" );
+            
+         if (!stream.good())
+               ERROR("template <class T> void CXMLParser::ParseInclude(const string& fluxId,  T& object)",
+                     << "[ filename = " << fluxId << " ] Bad xml stream !");
+
          StdOStringStream oss;
          while(!stream.eof() && !stream.fail ()) oss.put(stream.get());
@@ -20,4 +32,55 @@
             CXMLNode node(doc.first_node());
             object.parse(node);
+            currentIncludePath_ = parentPath ;    
+         }
+         catch (rapidxml::parse_error & exc)
+         {
+             const char* ptr = exc.where<char>() ;
+            const char* begin = xmlcontent.c_str() ;
+            const char* content=oss.str().c_str() ;
+            size_t pos=ptr-begin ;
+            int lineNumber = 1 ;
+            int columnNumber = 0 ;
+            const char* line;
+            const char* endLine;
+            
+            for(const char* i=content;i<content+pos; ++i, ++columnNumber) if (*i=='\n') { lineNumber++ ; line=i ; columnNumber=0 ;}
+            for(endLine=content+pos; *endLine!='\n' && *endLine!='\0' ; ++endLine) ;
+            string strLine(line,endLine-line) ;
+                  
+            ERROR("CXMLParser::ParseStream(StdIStream & stream)", << endl
+                  << "Error is occuring when parsing XML flux from <"<<fluxId<<"> at character "<< pos<<" line "<<lineNumber<<" column "<< columnNumber<< endl
+                  << strLine<<endl
+                  << string(columnNumber-1,'x')<<'^'<<endl)
+//                  <<" Error : " << exc.what() )
+         }
+      }
+
+      template <class T> void CXMLParser::ParseInclude(const string& fluxId,  T& object, const std::set<StdString>& parseContextList)
+      {
+         
+         string parentPath = currentIncludePath_ ;   // save current path     
+         string filePath = updateIncludePath(fluxId) ; // path is updated
+
+         StdIFStream stream(filePath, StdIFStream::in ) ;
+         if ( (stream.rdstate() & std::ifstream::failbit ) != 0 )
+               ERROR("template <class T> void CXMLParser::ParseInclude(const string& fluxId,  T& object)",
+                     <<endl<< "Can not open <"<<fluxId<<"> file" );
+            
+         if (!stream.good())
+               ERROR("template <class T> void CXMLParser::ParseInclude(const string& fluxId,  T& object)",
+                     << "[ filename = " << fluxId << " ] Bad xml stream !");
+
+
+         StdOStringStream oss;
+         while(!stream.eof() && !stream.fail ()) oss.put(stream.get());
+         const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 );
+         try
+         {
+            rapidxml::xml_document<char> doc;
+            doc.parse<0>(const_cast<char*>(xmlcontent.c_str()));
+            CXMLNode node(doc.first_node());
+            object.parse(node, true, parseContextList);
+            currentIncludePath_ = parentPath ;    // restore include path
          }
          catch (rapidxml::parse_error & exc)
