8
$\begingroup$

Bug present in 10.0.2 or earlier, and fixed in 10.4


If I try to export this toy code as ExpressionML or just XML:

data1 = {1, 2, 3, Plot[x, {x, 0, 10}]};
str1 = ExportString[data1, "ExpressionML"];
ImportString[str1]

I have no problem. Executing it, I get as expected:

ok example

But if I try to export some expression containing as Association like this:

data2 = {1, 2, 3, <|"a" -> 4, "b" -> 5|>};
str2 = ExportString[data2, "ExpressionML"];
(*ImportString[str2]*)

I get:

enter image description here

So, I can't export Associations. This is a bug no? Tested in Mathematia 10.0.2 for MAC.

UPDATE

A very clumsy workaround that I did was:

data3={1,2,3,<|"a"-> 4,"b"-> 5,"c"-><|"a"-> 4,"b"-> 5|>|>};
str3=ExportString[data3/.Association-> AssociationTemp,"ExpressionML"];
ImportString[str3]/.AssociationTemp-> Association

Note that for nested Associations, Replace works properly just from V10.0.2

$\endgroup$
  • $\begingroup$ Looks like a bug indeed. A job for support@wolfram.com I'd say. $\endgroup$ – Sjoerd C. de Vries Dec 27 '14 at 21:33
  • $\begingroup$ @SjoerdC.deVries I sent a formal report about it. $\endgroup$ – Murta Dec 28 '14 at 2:18
  • $\begingroup$ What are you using ExpressionML for? $\endgroup$ – Szabolcs Apr 1 '15 at 21:36
  • $\begingroup$ @Szabolcs to exchange code using the web between two Mathematicas. I did a rest service using WebMathematica, that another Mathematica can read. $\endgroup$ – Murta Apr 1 '15 at 23:14
  • 1
    $\begingroup$ @AlbertRetey at the time of this question, I was making some experiments transferring information between webMathematica servers. So I user expStr = ToString@FullForm[someExpression] to create the expression in string format, send it over Rest, and ToExpression@expStr in the other side to transform it back into Mathematica code. $\endgroup$ – Murta Nov 17 '15 at 12:14
2
$\begingroup$

This bug has been fixed as of version 10.4.0.

data2 = {1, 2, 3, <|"a" -> 4, "b" -> 5|>};
str2 = ExportString[data2, "ExpressionML"];
ImportString[str2]

(* {1, 2, 3, <|"a" -> 4, "b" -> 5|>} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.