Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

more quoting issues with XMLDump.mo

more quoting issues with XMLDump.mo

I've found some more quoting issues with XMLDump.mo, mainly spots where the text of an equation or constraint is spit out.  I'm not sure what the DTD for this XML format is, so I've been free with the way that the <function> tag is expressed.  I've also removed the unused import of Debug, just to avoid that error message.

Code:


Index: Compiler/BackEnd/XMLDump.mo
===================================================================
--- Compiler/BackEnd/XMLDump.mo    (revision 11108)
+++ Compiler/BackEnd/XMLDump.mo    (working copy)
@@ -92,7 +92,6 @@
protected import ComponentReference;
protected import Config;
protected import DAEUtil;
-protected import Debug;
protected import Dump;
protected import Error;
protected import Expression;
@@ -536,12 +535,15 @@
       list<Algorithm.Statement> stmts;
       Integer algNo,algNo_1;
       list<DAE.Algorithm> algs;
+      String s;
       
     case({},_) then ();
     case(DAE.ALGORITHM_STMTS(stmts)::algs,algNo)
       equation
         dumpStrOpenTagAttr(ALGORITHM, LABEL, stringAppend(stringAppend(ALGORITHM_REF,"_"),intString(algNo)));
-        Print.printBuf(DAEDump.dumpAlgorithmsStr({DAE.ALGORITHM(DAE.ALGORITHM_STMTS(stmts),DAE.emptyElementSource)}));
+        s = DAEDump.dumpAlgorithmsStr({DAE.ALGORITHM(DAE.ALGORITHM_STMTS(stmts),DAE.emptyElementSource)});
+        s = Util.xmlEscape(s);
+        Print.printBuf(s);
         dumpStrCloseTag(ALGORITHM);
         algNo_1=algNo+1;
         dumpAlgorithms2(algs,algNo_1);
@@ -2073,15 +2075,29 @@
algorithm
   _:= matchcontinue (fun)
     local
+/*
       Absyn.Path name;
+*/
+      String name;
+      String escapedFunctionText;
     case DAE.FUNCTION(type_ = DAE.T_FUNCTION(functionAttributes = DAE.FUNCTION_ATTRIBUTES(isBuiltin = DAE.FUNCTION_BUILTIN(_)))) then ();
     case(fun)
       equation
+/*
         name = DAEUtil.functionName(fun);
         Print.printBuf("\n<");Print.printBuf(FUNCTION);
         Print.printBuf(" ");Print.printBuf(FUNCTION_NAME);Print.printBuf("=\"");Print.printBuf(Absyn.pathStringNoQual(name));Print.printBuf("\"");
-        Print.printBuf(" ");Print.printBuf(MODELICA_IMPLEMENTATION);Print.printBuf("=\"");Print.printBuf(DAEDump.dumpFunctionStr(fun));
+        escapedFunctionText = Util.xmlEscape(DAEDump.dumpFunctionStr(fun));
+        Print.printBuf(" ");Print.printBuf(MODELICA_IMPLEMENTATION);Print.printBuf("=\"");Print.printBuf(escapedFunctionText);
         Print.printBuf("\"/>");
+*/
+        name = Util.xmlEscape(Absyn.pathStringNoQual(DAEUtil.functionName(fun)));
+        dumpStrOpenTagAttr(FUNCTION, FUNCTION_NAME, name);
+        dumpStrOpenTag(MODELICA_IMPLEMENTATION);
+        escapedFunctionText = Util.xmlEscape(DAEDump.dumpFunctionStr(fun));
+        Print.printBuf(escapedFunctionText);
+        dumpStrCloseTag(MODELICA_IMPLEMENTATION);
+        dumpStrCloseTag(FUNCTION);
       then();
     case (_) then();
/*
@@ -3452,6 +3468,7 @@
   _:=
   match (inZeroCrossingLst,addMathMLCode)
     local
+      String s;
       DAE.Exp e;
       Boolean addMMLCode;
       list<BackendDAE.Value> eq,wc;
@@ -3459,7 +3476,9 @@
     case ({},_) then ();
     case (BackendDAE.ZERO_CROSSING(relation_ = e,occurEquLst = eq,occurWhenLst = wc) :: zcLst,addMMLCode)
       equation
-        dumpStrOpenTagAttr(stringAppend(ZERO_CROSSING,ELEMENT_),EXP_STRING,ExpressionDump.printExpStr(e));
+        s = ExpressionDump.printExpStr(e);
+        s = Util.xmlEscape(s);
+        dumpStrOpenTagAttr(stringAppend(ZERO_CROSSING,ELEMENT_),EXP_STRING,s);
         dumpExp(e,addMMLCode);
         dumpLstIntAttr(eq,stringAppend(INVOLVED,EQUATIONS_),stringAppend(EQUATION,ID_));
         dumpLstIntAttr(wc,stringAppend(INVOLVED,stringAppend(WHEN_,EQUATIONS_)),stringAppend(WHEN,stringAppend(EQUATION_,ID_)));

There are 0 guests and 0 other users also viewing this topic
You are here: