src/Tools/isac/xmlsrc/interface-xml.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Sat, 29 Aug 2015 08:33:54 +0200
changeset 59168 c84d2d8c6592
parent 59165 4a8c2fd35d17
child 59169 eb815a2e7510
permissions -rw-r--r--
PIDE-phase 2c CONTINUED: IsaToJava.fetch_proposed_tac_out failed due to wrong XML conversion on SML-side
     1 (* interface between isac math engine and java:
     2    java -> sml: strings on stdin
     3    sml -> java: xml on stdout
     4 
     5    WN071004 The xml still reflects the insecurity during the first 
     6    implementation phase, how the communication via stdin/out could
     7    correctly relate multiple sml-calculations and java-calculations.
     8 
     9    Since this insecurity turned out unjustified, the xml can be
    10    simplified in several ways:
    11    # omit the CALCID; the relation is done by 
    12      "@@@@@begin@@@@@\n "^string_of_int uI
    13    # omit the distinctions APPENDFORMULA, REPLACEFORMULA, ...
    14    WN071004 these 2 simplifications are begun with CALCMESSAGE
    15 *)
    16 
    17 type iterID = int;
    18 type calcID = int;
    19 
    20 
    21 
    22 (** add and delete users -----------------------------------------------
    23  FIXXME.8.03 addUser: clear code, because only CalcTrees distinguished**)
    24 fun adduserOK2xml (cI:calcID) (uI:iterID) = 
    25     writeln ("@@@@@begin@@@@@\n "^string_of_int uI^" \n" ^
    26 	     "<ADDUSER>\n" ^
    27 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    28 	     "  <USERID> "^string_of_int uI^" </USERID>\n" ^
    29 	     "</ADDUSER>\n" ^
    30 	     "@@@@@end@@@@@");
    31 fun adduserOK2xml (calcid : calcID) (userid : iterID) =
    32   XML.Elem (("ADDUSER", []),
    33     [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
    34     XML.Elem (("USERID", []), [XML.Text (string_of_int userid)])])
    35 fun deluserOK2xml (cI:calcID) (uI:iterID) = 
    36     writeln ("@@@@@begin@@@@@\n "^string_of_int uI^" \n" ^
    37 	     "<DELUSER>\n" ^
    38 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    39 	     "  <USERID> "^string_of_int uI^" </USERID>\n" ^
    40 	     "</DELUSER>\n" ^
    41 	     "@@@@@end@@@@@");
    42 (*---------------------------------------------------------------------*)
    43 
    44 fun calctreeOK2xml (*uI:iterID*) (cI:calcID) = 
    45     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    46 	     "<CALCTREE>\n" ^
    47 	     "   <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    48 	     "</CALCTREE>\n" ^
    49 	     "@@@@@end@@@@@");
    50 fun calctreeOK2xml (calcid : calcID) = 
    51   XML.Elem (("CALCTREE", []),
    52     [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)])])    
    53 fun deconstructcalctreeOK2xml (*uI:userID*) (cI:calcID) = 
    54     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    55 	     "<DELCALC>\n" ^
    56 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    57 	     "</DELCALC>\n" ^
    58 	     "@@@@@end@@@@@");
    59 fun deconstructcalctreeOK2xml (calcid : calcID) = 
    60   XML.Elem (("DELCALC", []),
    61     [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)])])    
    62 
    63 fun iteratorOK2xml (cI:calcID) (p:pos')= 
    64     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    65 	     "<CALCITERATOR>\n" ^
    66 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    67 	     pos'2xml i ("POSITION", p) ^
    68 	     "</CALCITERATOR>\n" ^
    69 	     "@@@@@end@@@@@");
    70 fun iteratorERROR2xml (cI:calcID) = 
    71     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    72 	     "<CALCITERATOR>\n" ^
    73 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    74 	     "  <ERROR> iteratorERROR2xml: pos does not exist </ERROR>\n" ^
    75 	     "</CALCITERATOR>\n" ^
    76 	     "@@@@@end@@@@@");
    77 fun iteratorOK2xml (calcid : calcID) (p : pos')= 
    78   XML.Elem (("CALCITERATOR", []),
    79     [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
    80     xml_of_pos "POSITION" p])
    81 fun iteratorERROR2xml  (calcid : calcID) = 
    82   XML.Elem (("CALCITERATOR", []),
    83     [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
    84     XML.Elem (("ERROR", []), [XML.Text " iteratorERROR2xml: pos does not exist "])])
    85 
    86 fun sysERROR2xml (cI:calcID) "" = 
    87     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    88 	     "<SYSERROR>\n" ^
    89 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    90 	     "  <ERROR> in kernel </ERROR>\n" ^
    91 	     "</SYSERROR>\n" ^
    92 	     "@@@@@end@@@@@")
    93   | sysERROR2xml (cI:calcID) str = 
    94     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
    95 	     "<SYSERROR>\n" ^
    96 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
    97 	     "  <ERROR> "^str^" </ERROR>\n" ^
    98 	     "</SYSERROR>\n" ^
    99 	     "@@@@@end@@@@@");
   100 fun sysERROR2xml (calcid : calcID) str =
   101   XML.Elem (("SYSERROR", []),
   102     [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   103     XML.Elem (("ERROR", []), [XML.Text (if str = "" then " ERROR in kernel " else str)])])
   104 
   105 fun refformulaOK2xml (cI:calcID) p (Form t) = 
   106     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   107 	     "<REFFORMULA>\n" ^
   108              "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   109 	     "  <CALCFORMULA>\n"^
   110 	     pos'2xml (2*i) ("POSITION", p) ^
   111 	     "    <FORMULA>" ^
   112 	     term2xml (2*i) t ^ "\n" ^
   113 	     "    </FORMULA>\n" ^
   114 	     "  </CALCFORMULA>\n" ^
   115 	     "</REFFORMULA>\n" ^
   116 	     "@@@@@end@@@@@") 
   117   | refformulaOK2xml (cI:calcID) p (ModSpec modspec) =
   118     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   119 	     "<REFFORMULA>\n" ^
   120              "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   121 	     pos'calchead2xml i (p, modspec)^ 
   122 	     "</REFFORMULA>\n" ^
   123 	     "@@@@@end@@@@@"); 
   124 fun refformulaOK2xml (calcid : calcID) p (Form t) = 
   125       XML.Elem (("REFFORMULA", []),
   126         [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   127         XML.Elem (("CALCFORMULA", []), [
   128           xml_of_pos "POSITION" p,
   129           XML.Elem (("FORMULA", []), [xml_of_term t])])])
   130   | refformulaOK2xml (calcid : calcID) p (ModSpec modspec) = 
   131       XML.Elem (("REFFORMULA", []), [
   132         XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   133         (*L.Elem (("CALCHEAD*) xml_of_posmodspec (p, modspec)])
   134 
   135 fun refformulaERROR2xml (cI:calcID) = (*FIXME.WN.29.8.03 unused*)
   136     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   137 	     "<REFFORMULA>\n" ^
   138 	     "   <ERROR> object is not a formula </ERROR>\n" ^
   139 	     "</REFFORMULA>\n" ^
   140 	     "@@@@@end@@@@@");
   141 
   142 (* val (cI, tac) = (cI, ta);
   143    *)
   144 fun gettacticOK2xml (cI:calcID) tac = 
   145     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   146 	     "<GETTACTIC>\n" ^
   147 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n"^
   148 	     tac2xml i tac^
   149 	     "</GETTACTIC>\n" ^
   150 	     "@@@@@end@@@@@");
   151 fun gettacticOK2xml (calcid : calcID) tac = 
   152   XML.Elem (("GETTACTIC", []),[
   153     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   154     xml_of_tac tac])
   155 
   156 fun gettacticERROR2xml (cI:calcID) str = 
   157     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   158 	     "<GETTACTIC>\n" ^
   159 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   160 	     "  <ERROR> "^str^" </ERROR>\n" ^
   161 	     "</GETTACTIC>\n" ^
   162 	     "@@@@@end@@@@@");
   163 fun gettacticERROR2xml (calcid : calcID) str = 
   164   XML.Elem (("GETTACTIC", []),[
   165     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   166     XML.Elem (("ERROR", []), [XML.Text  str])])
   167 
   168 fun applicabletacticsOK cI tacs =
   169     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   170 	     "<APPLICABLETACTICS>\n" ^
   171 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   172 	     "  <TACLIST>\n"^
   173 	     tacs2xml (2*i) tacs^
   174 	     "  </TACLIST>\n" ^
   175 	     "</APPLICABLETACTICS>\n" ^
   176 	     "@@@@@end@@@@@");
   177 fun applicabletacticsOK calcid tacs =
   178   XML.Elem (("APPLICABLETACTICS", []), [
   179     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   180     XML.Elem (("TACLIST", []), (map xml_of_tac tacs))])
   181 
   182 fun getasmsOK2xml (cI:calcID) terms = 
   183     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   184 	     "<GETASSUMPTIONS>\n" ^
   185 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   186 	     "  <ASMLIST>\n"^
   187 	     formulae2xml (i+i) terms ^
   188 	     "  </ASMLIST>\n" ^
   189 	     "</GETASSUMPTIONS>\n" ^
   190 	     "@@@@@end@@@@@");
   191 fun getasmsOK2xml (calcid : calcID) terms = 
   192   XML.Elem (("ASSUMPTIONS", []), [
   193     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   194     XML.Elem (("ASMLIST", []), (map xml_of_formula terms))])
   195 
   196 (*WN0502 @see ME/ctree: type asms: illdesigned, thus not used*)
   197 fun getaccuasmsOK2xml cI asms =
   198     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   199 	     "<GETACCUMULATEDASMS>\n" ^
   200 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   201 	     "  <ASMLIST>\n"^
   202 	     formulae2xml (i+i) asms^
   203 	     "  </ASMLIST>\n" ^
   204 	     "</GETACCUMULATEDASMS>\n" ^
   205 	     "@@@@@end@@@@@");
   206 (* getaccuasmsOK2xml 333 [(([1],Res), str2term "1+1=2"),
   207 			  (([2],Res), str2term "1+1+1=3")];
   208    getaccuasmsOK2xml 333 [str2term "1+1=2", str2term "1+1+1=3"];
   209    *)
   210 
   211 fun getintervalOK (cI:calcID) fs = 
   212     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   213 	     "<GETELEMENTSFROMTO>\n" ^
   214 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   215 	     "  <FORMHEADS>\n"^	     
   216 	     posterms2xml (2*i) fs^
   217 	     "  </FORMHEADS>\n" ^	     
   218 	     "</GETELEMENTSFROMTO>\n" ^
   219 	     "@@@@@end@@@@@");
   220 fun getintervalOK (calcid : calcID) fs = 
   221       XML.Elem (("GETELEMENTSFROMTO", []),
   222         [XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   223         XML.Elem (("FORMHEADS", []), map xml_of_posterm fs)])
   224 
   225 fun matchpbl2xml (cI:calcID) (model_ok, pI, hdl, pbl, pre) =
   226     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   227 	     "<CONTEXTPBL>\n" ^
   228 	     "  <GUH> " ^ pblID2guh pI ^ " </GUH>\n" ^
   229 	     "  <STATUS> " ^ (if model_ok 
   230 			     then "correct" 
   231 			     else "incorrect") ^ " </STATUS>\n" ^
   232 	     "  <HEAD>\n" ^
   233 	     term2xml i hdl ^ "\n" ^
   234 	     "  </HEAD>\n" ^
   235 	     model2xml i pbl pre ^
   236 	     "</CONTEXTPBL>\n" ^
   237 	     "@@@@@end@@@@@");
   238 fun xml_of_matchpbl (_ : calcID) (model_ok, pI, hdl, pbl, pre) =
   239   XML.Elem (("CONTEXTPBL", []),
   240     ( (* WN150530: calcid will be required for asynchronous communication *)
   241     XML.Elem (("GUH", []), [XML.Text (pblID2guh pI)]) ::
   242     XML.Elem (("STATUS", []), [
   243       XML.Text ((if model_ok then "correct" else "incorrect"))]) ::
   244     XML.Elem (("HEAD", []), [xml_of_term hdl]) :: 
   245     (xml_of_model pbl pre) :: []))
   246 
   247 fun matchmet2xml (cI:calcID) (model_ok, pI, scr, pbl, pre) =
   248     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   249 	     "<CONTEXTMET>\n" ^
   250 	     "  <GUH> " ^ metID2guh pI ^ " </GUH>\n" ^
   251 	     "  <STATUS> " ^ (if model_ok 
   252 			     then "correct" 
   253 			     else "incorrect") ^ " </STATUS>\n" ^
   254 	     scr2xml i scr ^
   255 	     model2xml i pbl pre ^
   256 	     "</CONTEXTMET>\n" ^
   257 	     "@@@@@end@@@@@");
   258 fun xml_of_matchmet (_ : calcID) (model_ok, pI, scr, pbl, pre) =
   259   XML.Elem (("CONTEXTMET", []),
   260     ( (* WN150530: calcid will be required for asynchronous communication *)
   261     XML.Elem (("GUH", []), [XML.Text (pblID2guh pI)]) ::
   262     XML.Elem (("STATUS", []), [
   263       XML.Text ((if model_ok then "correct" else "incorrect"))]) ::
   264     XML.Elem (("HEAD", []), [xml_of_src scr]) :: 
   265     (xml_of_model pbl pre) :: []))
   266 
   267 fun tryrefineOK2xml (cI:calcID) (ModSpec modspec) =
   268     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   269 	     "<TRYREFINE>\n" ^
   270              "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   271 	     modspec2xml i modspec ^
   272 	     "</TRYREFINE>\n" ^
   273 	     "@@@@@end@@@@@"); 
   274 
   275 fun appendformulaOK2xml (cI:calcID) (old:pos') (del:pos') (new:pos') =
   276     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   277 	     "<APPENDFORMULA>\n" ^
   278 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   279 	     "  <CALCCHANGED>\n" ^
   280 	     pos'2xml (2*i) ("UNCHANGED", old) ^ 
   281 	     pos'2xml (2*i) ("DELETED", del) ^ 
   282 	     pos'2xml (2*i) ("GENERATED", new) ^ 
   283 	     "  </CALCCHANGED>\n" ^
   284 	     "</APPENDFORMULA>\n" ^
   285 	     "@@@@@end@@@@@");
   286 fun appendformulaOK2xml (calcid : calcID) (old : pos') (del : pos') (new : pos') = 
   287   xml_of_calcchanged calcid "APPENDFORMULA" old del new
   288 fun appendformulaERROR2xml (cI:calcID) msg =
   289     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   290 	     "<CALCMESSAGE> "^ msg ^" </CALCMESSAGE>\n" ^
   291 	     "@@@@@end@@@@@");
   292 fun appendformulaERROR2xml (calcid : calcID) e = 
   293   XML.Elem (("APPENDFORMULA", []), [
   294     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   295     XML.Elem (("CALCMESSAGE", []), [XML.Text e])])
   296 
   297 fun replaceformulaOK2xml (cI:calcID) (old:pos') (del:pos') (new:pos') =
   298     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   299 	     "<REPLACEFORMULA>\n" ^
   300 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   301 	     "  <CALCCHANGED>\n" ^
   302 	     pos'2xml (2*i) ("UNCHANGED", old) ^ 
   303 	     pos'2xml (2*i) ("DELETED", del) ^ 
   304 	     pos'2xml (2*i) ("GENERATED", new) ^ 
   305 	     "  </CALCCHANGED>\n" ^
   306 	     "</REPLACEFORMULA>\n" ^
   307 	     "@@@@@end@@@@@");
   308 fun replaceformulaOK2xml (calcid : calcID) (old : pos') (del : pos') (new : pos') = 
   309   xml_of_calcchanged calcid "REPLACEFORMULA" old del new
   310 fun replaceformulaERROR2xml (cI:calcID) msg =
   311     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   312 	     "<CALCMESSAGE> "^ msg ^" </CALCMESSAGE>\n" ^
   313 	     "@@@@@end@@@@@");
   314 fun replaceformulaERROR2xml (calcid : calcID) e = 
   315   XML.Elem (("REPLACEFORMULA", []), [
   316     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   317     XML.Elem (("CALCMESSAGE", []), [XML.Text e])])
   318 
   319 fun message2xml (cI:calcID) e = 
   320     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   321 	     "<MESSAGE>\n" ^
   322 	     "   <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   323 	     "   <STRING> "^e^" </STRING>\n" ^
   324 	     "</MESSAGE>\n" ^
   325 	     "@@@@@end@@@@@");
   326 fun message2xml (calcid : calcID) e = 
   327   XML.Elem (("MESSAGE", []), [
   328     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   329     XML.Elem (("STRING", []), [XML.Text e])])
   330 
   331 fun setnexttactic2xml (*uI:iterID*) (cI:calcID) e = 
   332     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   333 	     "<SETNEXTTACTIC>\n" ^
   334 	     "   <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   335 	     "   <MESSAGE> "^e^" </MESSAGE>\n" ^
   336 	     "</SETNEXTTACTIC>\n" ^
   337 	     "@@@@@end@@@@@");
   338 fun setnexttactic2xml (calcid : calcID) e = 
   339   XML.Elem (("SETNEXTTACTIC", []), [
   340     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   341     XML.Elem (("MESSAGE", []), [XML.Text e])])
   342 
   343 fun fetchproposedtacticOK2xml (cI:calcID) tac _ = 
   344     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   345 	     "<NEXTTAC>\n" ^
   346 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n"^
   347 	     tac2xml i tac^
   348 	     "</NEXTTAC>\n" ^
   349 	     "@@@@@end@@@@@");
   350 (*NEW JAVA*)
   351 fun fetchproposedtacticOK2xml (cI:calcID) tac (errpatIDs: errpatID list) = 
   352     writeln ("@@@@@begin@@@@@\n " ^ string_of_int cI ^ " \n" ^
   353 	     "<NEXTTAC>\n" ^
   354 	     "  <CALCID> " ^ string_of_int cI ^ " </CALCID>\n" ^
   355      "  <TACTICERRORPATTERNS>\n" ^
   356      id2xml (2*i) errpatIDs ^
   357 	     tac2xml (2*i) tac ^
   358 	     "  </TACTICERRORPATTERNS>\n" ^
   359      "</NEXTTAC>\n" ^
   360 	     "@@@@@end@@@@@");
   361 fun fetchproposedtacticOK2xml (calcid : calcID) tac (errpatIDs : errpatID list) = 
   362   XML.Elem (("NEXTTAC", []), [
   363     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   364     XML.Elem (("TACTICERRORPATTERNS", []), [xml_of_strs errpatIDs]),
   365     xml_of_tac tac])
   366 (*
   367 //  java.lang.IllegalArgumentException: fetch_proposed_tac_out wrong arg: 
   368  *  <NEXTTAC>
   369  *    <CALCID>1</CALCID>
   370  *    <TACTICERRORPATTERNS>
   371  *      <STRINGLIST/>
   372  *    <STRINGLISTTACTIC name="Apply_Method">
   373  *      <STRINGLIST>
   374  *        <STRING>Test</STRING>
   375  *        <STRING>squ-equ-test-subpbl1</STRING>
   376  *      </STRINGLIST>
   377  *    </STRINGLISTTACTIC>
   378  *  </TACTICERRORPATTERNS>
   379  *</NEXTTAC>
   380  *)
   381 
   382 fun fetchproposedtacticERROR2xml (*uI:userID*) (cI:calcID) e = 
   383     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   384 	     "<NEXTTAC>\n" ^
   385 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   386 	     "  <ERROR> "^ e ^" </ERROR>\n" ^
   387 	     "</NEXTTAC>\n" ^
   388 	     "@@@@@end@@@@@");
   389 fun fetchproposedtacticERROR2xml (calcid : calcID) e = 
   390   XML.Elem (("NEXTTAC", []), [
   391     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   392     XML.Elem (("ERROR", []), [XML.Text e])])
   393 
   394 (*. UNCHANGED: the pos' of the active formula autocalculate has been applied at
   395     DELETED:   last pos' of the succesional sequence of formulae prob. deleted
   396     GENERATED: the pos' of the new active formula
   397 .*)
   398 fun autocalculateOK2xml (cI:calcID) (old:pos') (del:pos') (new:pos') = 
   399     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   400 	     "<AUTOCALC>\n" ^
   401 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   402 	     "  <CALCCHANGED>\n" ^
   403 	     pos'2xml (2*i) ("UNCHANGED", old) ^ 
   404 	     pos'2xml (2*i) ("DELETED", del) ^ 
   405 	     pos'2xml (2*i) ("GENERATED", new) ^ 
   406 	     "  </CALCCHANGED>\n" ^
   407 	     "</AUTOCALC>\n" ^
   408 	     "@@@@@end@@@@@");
   409 fun autocalculateOK2xml (calcid : calcID) (old : pos') (del : pos') (new : pos') = 
   410   xml_of_calcchanged calcid "AUTOCALC" old del new
   411 fun autocalculateERROR2xml (cI:calcID) e = 
   412     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   413       (* WN150530: worked without cI ?!? FIXXME*)
   414 	     "<CALCMESSAGE> "^ e ^" </CALCMESSAGE>\n" ^
   415 	     "@@@@@end@@@@@");
   416 fun autocalculateERROR2xml (calcid : calcID) e = 
   417   XML.Elem (("AUTOCALC", []), [
   418     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   419     XML.Elem (("CALCMESSAGE", []), [XML.Text e])])
   420 
   421 fun interStepsOK (cI:calcID) (old:pos') (del:pos') (new:pos') =
   422     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   423 	     "<INTERSTEPS>\n" ^
   424 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   425 	     "  <CALCCHANGED>\n" ^
   426 	     pos'2xml (2*i) ("UNCHANGED", old) ^ 
   427 	     pos'2xml (2*i) ("DELETED", del) ^ 
   428 	     pos'2xml (2*i) ("GENERATED", new) ^ 
   429 	     "  </CALCCHANGED>\n" ^
   430 	     "</INTERSTEPS>\n" ^
   431 	     "@@@@@end@@@@@");
   432 fun interStepsOK (calcid : calcID) (old : pos') (del : pos') (new : pos') =
   433    xml_of_calcchanged calcid "INTERSTEPS" old del new
   434 fun interStepsERROR (cI:calcID) e =
   435     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   436 	     "  <CALCMESSAGE> "^ e ^" </CALCMESSAGE>\n" ^
   437 	     "@@@@@end@@@@@");
   438 fun interStepsERROR (calcid : calcID) e = 
   439   XML.Elem (("INTERSTEPS", []), [
   440     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   441     XML.Elem (("CALCMESSAGE", []), [XML.Text e])])
   442 
   443 fun calcMessage2xml (cI:calcID) e =
   444     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   445 	     "  <CALCMESSAGE> "^ e ^" </CALCMESSAGE>\n" ^
   446 	     "@@@@@end@@@@@");
   447 
   448 fun modifycalcheadOK2xml (cI:calcID) (chd as (complete,p_,_,_,_,_):ocalhd) =
   449     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   450 	     "<MODIFYCALCHEAD>\n" ^
   451 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   452 	     "  <STATUS> "^(if complete then "complete" 
   453 			    else "incomplete")^ "</STATUS>\n"^
   454 	     modspec2xml i chd^
   455 	     "</MODIFYCALCHEAD>\n" ^
   456 	     "@@@@@end@@@@@");
   457 fun modifycalcheadOK2xml (calcid : calcID) (chd as (complete, p_ ,_ ,_ ,_ ,_) : ocalhd) =
   458   XML.Elem (("MODIFYCALCHEAD", []), [
   459     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   460     XML.Elem (("STATUS", []), [
   461       XML.Text (if complete then "complete" else "incomplete")]),
   462     xml_of_modspec chd])
   463 
   464 fun contextthyOK2xml cI contthy = 
   465     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   466 	     "<CONTEXTTHY>\n" ^
   467 	     "  <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   468 	     contthy2xml i contthy ^
   469 	     "</CONTEXTTHY>\n" ^
   470 	     "@@@@@end@@@@@");
   471 fun contextthyOK2xml calcid contthy = 
   472   XML.Elem (("CONTEXTTHY", []), [
   473     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   474     XML.Elem (("CONTEXTDATA", []), xml_of_contthy contthy)])
   475 
   476 fun findFillpatterns2xml (cI:calcID) pattIDs = 
   477     writeln ("@@@@@begin@@@@@\n "^string_of_int cI^" \n" ^
   478 	     "<FINDFILLPATTERNS>\n" ^
   479 	     "   <CALCID> "^string_of_int cI^" </CALCID>\n" ^
   480 	     id2xml 3 pattIDs ^
   481 	     "</FINDFILLPATTERNS>\n" ^
   482 	     "@@@@@end@@@@@");
   483 fun findFillpatterns2xml (calcid : calcID) pattIDs = 
   484   XML.Elem (("FINDFILLPATTERNS", []), [
   485     XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
   486     xml_of_strs pattIDs])
   487