Discussion:
more about reading stuff from a wxMaxima file
(too old to reply)
Robert Dodier
2016-12-13 05:39:09 UTC
Permalink
Raw Message
I've packaged my previous experiment as:
https://github.com/robert-dodier/maxima-read-wxmx
I've added some code to extract the content.xml from a wxmx file, which
is just a zip file with a certain structure. At this point it's possible
to run the Maxima interpreter on the input in a wxmx file. See the
README file for more information and an example.

Hope this is useful to someone.

best,

Robert Dodier
Gunter Königsmann
2017-07-20 16:15:49 UTC
Permalink
Raw Message
Post by Robert Dodier
https://github.com/robert-dodier/maxima-read-wxmx
I've added some code to extract the content.xml from a wxmx file, which
is just a zip file with a certain structure. At this point it's possible
to run the Maxima interpreter on the input in a wxmx file. See the
README file for more information and an example.
Hope this is useful to someone.
Dear Robert,

Ever since you wrote this piece of code I thought about if there was a
way to include it without dropping gcl due to all known zip readers
requiring asdf.

Perhaps I have an idea now:
wxMaxima's .wxmx format doesn't use .zip because it provides compression:
- the images are included as .png files and therefore already
compressed. Trying to compress them again normally doesn't reduce their size
- the text provided by the user normally is small enough to be shipped
by an ordinary E-Mail
- and if a version control system is used any compression actually
increases the amount of disk space being used as a 1-line-change in the
uncompressed text will result in a comparatively big change in the
compressed version
=> I have now removed the possibility to enable compression manually.

The file format from now on therefore consists of
- a .zip header
- starting from byte 32 the text "mimetypetext/x-wxmathml"
- then a textual description of the format that doesn't contain the
string "<wxMaximaDocument"
- then the actual worksheet that your code can read. The worksheet
starts with "<wxMaximaDocument"
- The XML escaping rules make sure that the worksheet itself never
contains the string "</wxMaximaDocument>" except at the ending of the
final line
- and the final line of the worksheet ends in </wxMaximaDocument>

Since the text no more is compressed in theory this would allow the
.wxmx reader to read .wxmx files without the need of a zip archive
handler: A search for the document's begin and end in the .zip file
would be sufficient.

Reading .wxmx files from old wxMaxima versions that still use
compression will fail this way. But... ...there are worse things than that.

Kind regards,

Gunter.
Robert Dodier
2017-07-20 17:17:41 UTC
Permalink
Raw Message
Post by Gunter Königsmann
Reading .wxmx files from old wxMaxima versions that still use
compression will fail this way. But... ...there are worse things than that.
I don't have an opinion one way or the other about the format for
wxMaxima files. But it seems likely that you'll want to get the
wxMaxima project on board with any change to the default file
format. Certainly a change which makes some files unreadable
will cause a certain amount of trouble.

Although reading wxMaxima files from Maxima would be nice,
I think you'll need to get buy-in from wxMaxima -- what anybody
on the Maxima team thinks about it is secondary, I'm pretty sure.

best,

Robert Dodier
Gunter Königsmann
2017-07-20 17:55:05 UTC
Permalink
Raw Message
Arrgh!

Seems like I formulated my mail in the completely wrong way:

wxMaxima 17.04 can still open files from 2012 and vice versa and I won't change that unless that is absolutely necessary (which is unlikely as mathematics doesn't tend to change abruptly and therefore the program that merely displays maths doesn't need to do so, neither). Actually the 2017 version will be able to open broken files from 2013 that the 2013 version isn't.

But I wanted to tell you that since 2015 nearly no new .wxmx file requires a .zip decompressor to read which means that your .wxmx parser might be able to read them without requiring a lisp package manager.

...and that the next wxMaxima version will only generate .wxmx files that are easier to interpret from the Maxima side.

Kind regards,

Gunter
--
Diese Nachricht wurde von meinem Android-GerÀt mit K-9 Mail gesendet.
Gunter Königsmann
2017-07-21 06:19:19 UTC
Permalink
Raw Message
Post by Gunter Königsmann
...and that the next wxMaxima version will only generate .wxmx files
that are easier to interpret from the Maxima side.
Found a way to make a hexdump that isn't too wide for being included in
an e-mail =>

The file header:
00000000 50 4b 03 04 14 00 00 00 |PK......|
00000008 00 00 33 3b f5 4a f1 42 |..3;.J.B|
00000010 96 48 0f 00 00 00 0f 00 |.H......|
00000018 00 00 08 00 00 00 6d 69 |......mi|
00000020 6d 65 74 79 70 65 74 65 |metypete|
00000028 78 74 2f 78 2d 77 78 6d |xt/x-wxm|
00000030 61 74 68 6d 6c 50 4b 03 |athmlPK.|

<skipping the part of the file that contains a plain english description
of the file format>

What now follows is a version of content.xml that isn't compressed - and
therefore can be interpreted by maxima is "&gt;" is replaced by ">" and
"&lt;" is replaced by "<":

00000670 65 2e 0a 0a 50 4b 03 04 |e...PK..|
00000678 14 00 00 00 00 00 33 3b |......3;|
00000680 f5 4a a6 f7 55 f5 9f 03 |.J..U...|
00000688 00 00 9f 03 00 00 0b 00 |........|
00000690 00 00 63 6f 6e 74 65 6e |..conten|
00000698 74 2e 78 6d 6c 3c 3f 78 |t.xml<?x|
000006a0 6d 6c 20 76 65 72 73 69 |ml versi|
000006a8 6f 6e 3d 22 31 2e 30 22 |on="1.0"|
000006b0 20 65 6e 63 6f 64 69 6e | encodin|
000006b8 67 3d 22 55 54 46 2d 38 |g="UTF-8|
000006c0 22 3f 3e 0a 0a 3c 21 2d |"?>..<!-|
000006c8 2d 20 20 20 43 72 65 61 |- Crea|
000006d0 74 65 64 20 62 79 20 77 |ted by w|
000006d8 78 4d 61 78 69 6d 61 20 |xMaxima |
000006e0 31 37 2e 30 37 2e 30 20 |17.07.0 |
000006e8 20 20 2d 2d 3e 0a 3c 21 | -->.<!|
000006f0 2d 2d 68 74 74 70 3a 2f |--http:/|
000006f8 2f 77 78 6d 61 78 69 6d |/wxmaxim|
00000700 61 2e 73 6f 75 72 63 65 |a.source|
00000708 66 6f 72 67 65 2e 6e 65 |forge.ne|
00000710 74 2d 2d 3e 0a 0a 3c 77 |t-->..<w|
00000718 78 4d 61 78 69 6d 61 44 |xMaximaD|
00000720 6f 63 75 6d 65 6e 74 20 |ocument |
00000728 76 65 72 73 69 6f 6e 3d |version=|
00000730 22 31 2e 35 22 20 7a 6f |"1.5" zo|
00000738 6f 6d 3d 22 31 39 30 22 |om="190"|
00000740 20 61 63 74 69 76 65 63 | activec|
00000748 65 6c 6c 3d 22 33 22 3e |ell="3">|
00000750 0a 0a 3c 63 65 6c 6c 20 |..<cell |
00000758 74 79 70 65 3d 22 63 6f |type="co|
00000760 64 65 22 3e 0a 3c 69 6e |de">.<in|
00000768 70 75 74 3e 0a 3c 65 64 |put>.<ed|
00000770 69 74 6f 72 20 74 79 70 |itor typ|
00000778 65 3d 22 69 6e 70 75 74 |e="input|
00000780 22 3e 0a 3c 6c 69 6e 65 |">.<line|
00000788 3e 69 6e 74 65 67 72 61 |>integra|
00000790 74 65 28 66 28 78 29 2c |te(f(x),|
00000798 78 2c 31 2c 31 30 29 3b |x,1,10);|
000007a0 3c 2f 6c 69 6e 65 3e 0a |</line>.|
000007a8 3c 2f 65 64 69 74 6f 72 |</editor|
000007b0 3e 0a 3c 2f 69 6e 70 75 |>.</inpu|
000007b8 74 3e 0a 3c 6f 75 74 70 |t>.<outp|
000007c0 75 74 3e 0a 3c 6d 74 68 |ut>.<mth|
000007c8 3e 3c 6c 62 6c 3e 28 25 |><lbl>(%|
000007d0 6f 31 29 20 3c 2f 6c 62 |o1) </lb|
000007d8 6c 3e 3c 69 6e 3e 3c 72 |l><in><r|
000007e0 3e 3c 6e 3e 31 3c 2f 6e |><n>1</n|
000007e8 3e 3c 2f 72 3e 3c 72 3e |></r><r>|
000007f0 3c 6e 3e 31 30 3c 2f 6e |<n>10</n|
000007f8 3e 3c 2f 72 3e 3c 72 3e |></r><r>|
00000800 3c 66 6e 3e 3c 72 3e 3c |<fn><r><|
00000808 66 6e 6d 3e 66 3c 2f 66 |fnm>f</f|
00000810 6e 6d 3e 3c 2f 72 3e 3c |nm></r><|
00000818 72 3e 3c 70 3e 3c 76 3e |r><p><v>|
00000820 78 3c 2f 76 3e 3c 2f 70 |x</v></p|
00000828 3e 3c 2f 72 3e 3c 2f 66 |></r></f|
00000830 6e 3e 3c 2f 72 3e 3c 72 |n></r><r|
00000838 3e 3c 73 3e 64 3c 2f 73 |><s>d</s|
00000840 3e 3c 76 3e 78 3c 2f 76 |><v>x</v|
00000848 3e 3c 2f 72 3e 3c 2f 69 |></r></i|
00000850 6e 3e 0a 3c 2f 6d 74 68 |n>.</mth|
00000858 3e 3c 2f 6f 75 74 70 75 |></outpu|
00000860 74 3e 0a 3c 2f 63 65 6c |t>.</cel|
00000868 6c 3e 0a 0a 3c 63 65 6c |l>..<cel|
00000870 6c 20 74 79 70 65 3d 22 |l type="|
00000878 63 6f 64 65 22 3e 0a 3c |code">.<|
00000880 69 6e 70 75 74 3e 0a 3c |input>.<|
00000888 65 64 69 74 6f 72 20 74 |editor t|
00000890 79 70 65 3d 22 69 6e 70 |ype="inp|
00000898 75 74 22 3e 0a 3c 6c 69 |ut">.<li|
000008a0 6e 65 3e 73 69 6e 28 78 |ne>sin(x|
000008a8 29 3b 3c 2f 6c 69 6e 65 |);</line|
000008b0 3e 0a 3c 2f 65 64 69 74 |>.</edit|
000008b8 6f 72 3e 0a 3c 2f 69 6e |or>.</in|
000008c0 70 75 74 3e 0a 3c 6f 75 |put>.<ou|
000008c8 74 70 75 74 3e 0a 3c 6d |tput>.<m|
000008d0 74 68 3e 3c 6c 62 6c 3e |th><lbl>|
000008d8 28 25 6f 31 29 20 3c 2f |(%o1) </|
000008e0 6c 62 6c 3e 3c 66 6e 3e |lbl><fn>|
000008e8 3c 72 3e 3c 66 6e 6d 3e |<r><fnm>|
000008f0 73 69 6e 3c 2f 66 6e 6d |sin</fnm|
000008f8 3e 3c 2f 72 3e 3c 72 3e |></r><r>|
00000900 3c 70 3e 3c 76 3e 78 3c |<p><v>x<|
00000908 2f 76 3e 3c 2f 70 3e 3c |/v></p><|
00000910 2f 72 3e 3c 2f 66 6e 3e |/r></fn>|
00000918 0a 3c 2f 6d 74 68 3e 3c |.</mth><|
00000920 2f 6f 75 74 70 75 74 3e |/output>|
00000928 0a 3c 2f 63 65 6c 6c 3e |.</cell>|
00000930 0a 0a 3c 63 65 6c 6c 20 |..<cell |
00000938 74 79 70 65 3d 22 63 6f |type="co|
00000940 64 65 22 3e 0a 3c 69 6e |de">.<in|
00000948 70 75 74 3e 0a 3c 65 64 |put>.<ed|
00000950 69 74 6f 72 20 74 79 70 |itor typ|
00000958 65 3d 22 69 6e 70 75 74 |e="input|
00000960 22 3e 0a 3c 6c 69 6e 65 |">.<line|
00000968 3e 73 69 6e 28 78 2b 61 |>sin(x+a|
00000970 2f 32 29 3b 3c 2f 6c 69 |/2);</li|
00000978 6e 65 3e 0a 3c 2f 65 64 |ne>.</ed|
00000980 69 74 6f 72 3e 0a 3c 2f |itor>.</|
00000988 69 6e 70 75 74 3e 0a 3c |input>.<|
00000990 6f 75 74 70 75 74 3e 0a |output>.|
00000998 3c 6d 74 68 3e 3c 6c 62 |<mth><lb|
000009a0 6c 3e 28 25 6f 32 29 20 |l>(%o2) |
000009a8 3c 2f 6c 62 6c 3e 3c 66 |</lbl><f|
000009b0 6e 3e 3c 72 3e 3c 66 6e |n><r><fn|
000009b8 6d 3e 73 69 6e 3c 2f 66 |m>sin</f|
000009c0 6e 6d 3e 3c 2f 72 3e 3c |nm></r><|
000009c8 72 3e 3c 70 3e 3c 76 3e |r><p><v>|
000009d0 78 3c 2f 76 3e 3c 76 3e |x</v><v>|
000009d8 2b 3c 2f 76 3e 3c 66 3e |+</v><f>|
000009e0 3c 72 3e 3c 76 3e 61 3c |<r><v>a<|
000009e8 2f 76 3e 3c 2f 72 3e 3c |/v></r><|
000009f0 72 3e 3c 6e 3e 32 3c 2f |r><n>2</|
000009f8 6e 3e 3c 2f 72 3e 3c 2f |n></r></|
00000a00 66 3e 3c 2f 70 3e 3c 2f |f></p></|
00000a08 72 3e 3c 2f 66 6e 3e 0a |r></fn>.|
00000a10 3c 2f 6d 74 68 3e 3c 2f |</mth></|
00000a18 6f 75 74 70 75 74 3e 0a |output>.|
00000a20 3c 2f 63 65 6c 6c 3e 0a |</cell>.|
00000a28 0a 3c 2f 77 78 4d 61 78 |.</wxMax|
00000a30 69 6d 61 44 6f 63 75 6d |imaDocum|
00000a38 65 6e 74 3e 50 4b 01 02 |ent>PK..|

The rest of the file contains png images and the zip directory - which
both aren't needed in order to interpret the code from maxima.

Loading...