/**********************************************************************
*
*      Projet  : DilibXml
*      Module  : SxmlProc
*      Fichier : Test/xmlDomProcInter.c
*      Auteur  : J. Ducloy
*
*      Derniere mise a jour Decembre 2001
*
***********************************************************************
*
*  Mini interpret for:
*       Testing XmlProcessor and XmlDomProc
*       Demonstration
*
************************************************************************
* 
*     Copyrigth (C) 2001 Jacques DUCLOY & CNRS INIST
*
***********************************************************************/

#include "SxmlProcessor.h"
#include "SxmlDomProc.h"
#include <stdlib.h>

int main()
{
  SxmlNode *mem1;
  SxmlNode *p1;
  SxmlNode *step;

  mem1=SxmlMemoryCreate();
  p1=SxmlProcessorCreate(mem1);
  SxmlDomMemoryInit(mem1);

  while ((step=SxmlInputNextDocumentElement()))
    {
      SxmlNode *res;

      /* following statement is requested to memorize Sxml fragments
         which could be contained in scripts.
         Thus, SxmlRemoveChild() is mandatory
         We have choosen to create main function for storing these fragments...
      */

      SxmlMemoryAppendToFunction(mem1,"main",SxmlRemoveChild(step));

      res= SxmlProcessorEvalToNode(p1,step);
      if(res)
	{
	  SxmlPrint(res);
	  putchar ('\n');
	}
    }
  exit (0);
  return 0;
}
