Index: XIOS/trunk/bld.cfg
===================================================================
--- XIOS/trunk/bld.cfg	(revision 461)
+++ XIOS/trunk/bld.cfg	(revision 462)
@@ -30,7 +30,6 @@
 bld::lib xios
 bld::target libxios.a
-#bld::target test.exe
-bld::target generate_fortran_interface.exe 
-bld::target xios_server.exe test_cs.exe test_client.exe test_unstruct.exe
+#bld::target generate_fortran_interface.exe 
+bld::target xios_server.exe test_client.exe parse_xml.exe
 bld::exe_dep
 
Index: XIOS/trunk/src/group_parser.hpp
===================================================================
--- XIOS/trunk/src/group_parser.hpp	(revision 461)
+++ XIOS/trunk/src/group_parser.hpp	(revision 462)
@@ -20,8 +20,11 @@
          {
             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, *this);
+            xml::CXMLParser::ParseInclude(ifs, attributes["src"].c_str(), *this);
          }
       }
Index: XIOS/trunk/src/group_template_impl.hpp
===================================================================
--- XIOS/trunk/src/group_template_impl.hpp	(revision 461)
+++ XIOS/trunk/src/group_template_impl.hpp	(revision 462)
@@ -490,8 +490,12 @@
          {
             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, *this);
+            xml::CXMLParser::ParseInclude(ifs, attributes["src"].c_str(), *this);
          }
       }
Index: XIOS/trunk/src/node/context.cpp
===================================================================
--- XIOS/trunk/src/node/context.cpp	(revision 461)
+++ XIOS/trunk/src/node/context.cpp	(revision 462)
@@ -110,8 +110,11 @@
       {
          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, *this);
+         xml::CXMLParser::ParseInclude(ifs, attributes["src"], *this);
       }
 
Index: XIOS/trunk/src/test/parse_xml.cpp
===================================================================
--- XIOS/trunk/src/test/parse_xml.cpp	(revision 462)
+++ XIOS/trunk/src/test/parse_xml.cpp	(revision 462)
@@ -0,0 +1,10 @@
+#include "cxios.hpp"
+
+
+using namespace std ;
+using namespace xios ;
+
+int main (int argc, char ** argv, char ** UNUSED (env))
+{
+  CXios::initialize() ;
+}
Index: XIOS/trunk/src/xml_parser.cpp
===================================================================
--- XIOS/trunk/src/xml_parser.cpp	(revision 461)
+++ XIOS/trunk/src/xml_parser.cpp	(revision 462)
@@ -16,5 +16,9 @@
       {
          StdIFStream ifs ( filename.c_str() , StdIFStream::in );
-         CXMLParser::ParseStream(ifs);
+         if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 )
+           ERROR("void CXMLParser::ParseFile(const StdString & filename)",
+                  <<endl<< "Can not open <"<<filename<<"> file" );
+
+         CXMLParser::ParseStream(ifs, filename);
       }
 
@@ -22,8 +26,8 @@
       {
          StdIStringStream iss ( xmlContent /*, StdIStringStream::in*/ );
-         CXMLParser::ParseStream(iss);
+         CXMLParser::ParseStream(iss,"string");
       }
 
-      void CXMLParser::ParseStream(StdIStream & stream)
+      void CXMLParser::ParseStream(StdIStream & stream, const string& fluxId)
       {
          if (!stream.good())
@@ -31,10 +35,8 @@
                   << "Bad xml stream !");
          StdOStringStream oss;
-         while(!stream.eof() && !stream.fail ())
-            oss.put(stream.get());
+         while(!stream.eof() && !stream.fail ()) oss.put(stream.get());
+         const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 );
          try
          {
-            //const StdString xmlcontent( oss.str(), 0, oss.str().size()-2); //<POURQUOI ?
-            const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 );
             rapidxml::xml_document<char> doc;
             doc.parse<0>(const_cast<char*>(xmlcontent.c_str()));
@@ -58,5 +60,5 @@
                   if (attributes.end() == attributes.find("id"))
                   {  
-                     DEBUG("Le context ne sera pas traitÃ© car il n'est pas identifiÃ© !");
+                     DEBUG("The context will not be processed because it is not identified (missing id)");
                      continue; 
                   }
@@ -68,6 +70,5 @@
                   if(hasctxt)
                   {  
-                     DEBUG("Le context ne sera pas traitÃ© car "
-                           << "il existe dÃ©jÃ  un autre context possÃ©dant le mÃªme nom !");
+                     DEBUG("The context will not be processed because it exist an other context with the same id" );
                      continue; 
                   }
@@ -84,6 +85,22 @@
          catch (rapidxml::parse_error & exc)
          {
-            ERROR("CXMLParser::ParseStream(StdIStream & stream)",
-                  << "RapidXML error : " << exc.what() << " !");
+            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() )
          }
       }
Index: XIOS/trunk/src/xml_parser.hpp
===================================================================
--- XIOS/trunk/src/xml_parser.hpp	(revision 461)
+++ XIOS/trunk/src/xml_parser.hpp	(revision 462)
@@ -19,7 +19,7 @@
             static void ParseFile(const StdString & filename);
             static void ParseString(const StdString & xmlContent);
-            static void ParseStream(StdIStream & stream);
+            static void ParseStream(StdIStream & stream, const string& fluxId);
             template <class T>
-               static void ParseInclude(StdIStream & stream, T & object);
+               static void ParseInclude(StdIStream & stream, const string& fluxId, T & object);
 
       }; //class CXMLParser
Index: XIOS/trunk/src/xml_parser_decl.cpp
===================================================================
--- XIOS/trunk/src/xml_parser_decl.cpp	(revision 461)
+++ XIOS/trunk/src/xml_parser_decl.cpp	(revision 462)
@@ -13,8 +13,8 @@
   namespace xml
   {
-    template void CXMLParser::ParseInclude<CContext>(StdIStream & stream, CContext& object) ;
+    template void CXMLParser::ParseInclude<CContext>(StdIStream & stream, const string& fluxId, CContext& object) ;
  
  #   define macro(T) \
-    template void CXMLParser::ParseInclude< CGroupTemplate<C##T, C##T##Group, C##T##Attributes> >(StdIStream & stream, CGroupTemplate<C##T, C##T##Group, C##T##Attributes>& object) ;
+    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) ;
     
     macro( Context ) 
Index: XIOS/trunk/src/xml_parser_impl.hpp
===================================================================
--- XIOS/trunk/src/xml_parser_impl.hpp	(revision 461)
+++ XIOS/trunk/src/xml_parser_impl.hpp	(revision 462)
@@ -9,12 +9,11 @@
    namespace xml
    {
-     template <class T> void CXMLParser::ParseInclude(StdIStream & stream, T& object)
+     template <class T> void CXMLParser::ParseInclude(StdIStream & stream, const string& fluxId,  T& object)
       {
          StdOStringStream oss;
-         while(!stream.eof() && !stream.fail ())
-            oss.put(stream.get());
+         while(!stream.eof() && !stream.fail ()) oss.put(stream.get());
+         const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 );
          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()));
@@ -24,6 +23,22 @@
          catch (rapidxml::parse_error & exc)
          {
-            ERROR("CXMLParser::ParseStream(StdIStream & stream)",
-                  << "RapidXML error : " << exc.what() << " !");
+             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() )
          }
       }
