0 Replies Latest reply: May 14, 2013 4:52 AM by 1008793 RSS

    Unmarshal a modified xml file

    1008793
      Hi,

      In my java project I need to unmarshal an xml file in order to get a list of objects.

      The unmarshalling works very fine but the problem is encontourned when the content of the file is modified. In fact in this project we can add new contents to this file by clicking on "addButon" but when i want to unmarshal another time the same file (after modification) i get only the old list of objects without the last elements (I have just added to this file).

      I already verified the physical xml file on the disk and I found all the last content I just added. Also I noticed that The only way to get the last list of objects is to close the appli and to reopen it again, which is unsuitable.

      Here is a piece of the code:

      //classe1.java

      Referentiel ref = null;
      File iniFile = new File(proprietesPerle.getRepReferentiel() + "referential.xml");


      FileInputStream fs = null;
      try
      {     

      fs = new FileInputStream(iniFile);     

      }

      catch(FileNotFoundException fex)
      {
      ....
      }

      try
      {
      ref = Referentiel.unmarshal(fs);     

      session.setAttribute("ref",(Object) ref);

      TreeMap map = ReferentielUtil.getApplication( ref );

      session.setAttribute("mapAppli", map);
      }
      catch (UnmarshalException ex)
      {
      logger.error(ex.getMessage());
      }
      finally {

      try {

      fs.close();

      } catch (IOException e) {
      logger.error(e.getMessage());     
      }

      }

      ...


      //classe2.java

      TreeMap map = new TreeMap();

      List listPL = app.getPl(); //this list is unmarshalled from the xml file

      ListIterator itpl = listPL.listIterator();

      while (itpl.hasNext())
      {

      Pl pl = (Pl)itpl.next();

      map.put(pl.getCode(), pl);
      }

      return map;

      ...

      Please, do you have any idea to resolve this problem?
      Thank you in advance.