Home > Net >  How to interprete a section in XML file containing graphical information?
How to interprete a section in XML file containing graphical information?

Time:11-17

I try to interprete an XML file of a diagram that is created with diagrams.net. All graphical elements can easily be read but the encoding of the freehand tool is not readable. Although I select saving without compression this part may be saved netherteless in compressed format? There is an apparently random sequence of letters, numbers, and some special characters ( ,/, =) to describe the short stroke seen here:

The stroke encoding starts in the 2nd line after stencil( (full code is found here).

How the stroke is encoded in this sequence?

<mxCell id="c7RGBG_HR7ZXm5QX32jH-9" value="" style="shape=
stencil(lZTdboMwDIWfhlsrsZM4ue6696hUOtAYVJTu5 1nFG0jSPOWu2DOF/s4lhs63Lr
TtW3Q3JZ5em7f vPSNfTQIPZj1879IqeGjg0dLtPcPs3TfTzn7 tpVa6nl l1veE9cwaMWSE0Hzlgz
XfoMQNDP24ACxarAA/RFkAMEFhJQGBSAbAFRwoQAEsPQc8gHogLwEcgJQMy NKDE1cKQATJFYBEtA
zOAMcCkL5pXXUMWJZkddMe9x6sRLR3E9OlB71JQa4ru rAKgUFBhcKvT5HMgWcavQeUqzRpy97/9NHB
KypP8qDVukZ2Nbo037mdH1CMFV6AsYavQf0NfqwH9A/9NIfrtFHiDXzsNlrvwFy N
mrl34Y8lre/t/vYQnlHU7HTw==);
fillColor=none;" vertex="1" parent="1"> <mxGeometry x="277.5999755859375"
y="238.19998168945312" width="71.60000610351562" height="2.399993896484375" 
as="geometry" />  </mxCell>

If I save it as SVG file then the coordinates are readable (full SVG code).

path d="M -0.4 2.6 L 0.4 2.6 L 3.76 2.28 L 8.97 1.91 L 11.2 1.8 L 14.9 1.6 L 19.3 1.3 L 23.9 1 L 28.8 0.8 L 33.4 0.6 L 37.2 0.5 L 40.8 0.4 L 44.4 0.3 L 47.9 0.2 L 51 0.2 L 54 0.2 L 56.4 0.2 L 58.5 0.2 L 60.5 0.2 L 62.4 0.2 L 64 0.2 L 65.5 0.2 L 66.7 0.2 L 67.8 0.2 L 68.7 0.2 L 69.6 0.2 L 70.4 0.2 L 71.2 0.2"

The freehand tool can be found in the Menu Arrange->Insert->Freehand. The XML is saved without compression in Menu File->Export as->XML.

CodePudding user response:

The original text was Base64 encoded then compressed by deflate and URL encoded. The original text can be reconstructed by:

  1. Base64 decode
  2. Inflate
  3. URL decode

A conversion tool and description is found here:

https://j2r2b.github.io/2019/08/01/drawio-decompressed-xml.html

Python 3. code

import base64,zlib,urllib
decoded_text=urllib.parse.unquote(zlib.decompress(base64.b64decode(encoded_text),wbits=-15))

The compressed code of the OP is

lZTdboMwDIWfhlsrsZM4ue6696hUOtAYVJTu5 1nFG0jSPOWu2DOF/s4lhs63Lr
TtW3Q3JZ5em7f vPSNfTQIPZj1879IqeGjg0dLtPcPs3TfTzn7 tpVa6nl l1ve
E9cwaMWSE0HzlgzXfoMQNDP24ACxarAA/RFkAMEFhJQGBSAbAFRwoQAEsPQc8gH
ogLwEcgJQMy NKDE1cKQATJFYBEtAzOAMcCkL5pXXUMWJZkddMe9x6sRLR3E9Ol
B71JQa4ru rAKgUFBhcKvT5HMgWcavQeUqzRpy97/9NHBKypP8qDVukZ2Nbo037
mdH1CMFV6AsYavQf0NfqwH9A/9NIfrtFHiDXzsNlrvwFy Nmrl34Y8lre/t/vYQ
nlHU7HTw==

and after conversion (using the tool or python):

<shape strokewidth="inherit"><foreground><path><move x="0.00"
y="100.00"/><line x="1.12" y="100.00"/><line x="5.81" y="86.67"/>
<line x="13.09" y="71.43"/><line x="16.20" y="66.67"/><line x="21.37"
 y="58.33"/><line x="27.51" y="45.83"/><line x="33.94" y="33.33"/>
<line x="40.78" y="25.00"/><line x="47.21" y="16.67"/><line x="52.51"
 y="12.50"/><line x="57.54" y="8.33"/><line x="62.57" y="4.17"/>
<line x="67.46" y="0.00"/><line x="71.79" y="0.00"/><line x="75.98"
 y="0.00"/><line x="79.33" y="0.00"/><line x="82.26" y="0.00"/>
<line x="85.06" y="0.00"/><line x="87.71" y="0.00"/><line x="89.94"
 y="0.00"/><line x="92.04" y="0.00"/><line x="93.72" y="0.00"/>
<line x="95.25" y="0.00"/><line x="96.51" y="0.00"/><line x="97.77"
 y="0.00"/><line x="98.88" y="0.00"/><line x="100.00" y="0.00"/>
</path><fillstroke/></foreground></shape>
  • Related