From 14KB to 1.38MB ?!

Aug 23, 2008 at 3:13 PM
Hi guys,

I want to use your XamlTune-Project to automaticly convert SVG-files (created by Graphviz) to XAML. Therefore I'm using this code:

private void transformSvgToXaml(String svg, String xamlFile)
{
            String result = Svg2Xaml.ConvertFromSVG(svg);
            StreamWriter write = new StreamWriter(xamlFile);
            write.WriteLine(result);
            write.Close();
}

The problem: the original file is 14gb big, the xaml-file is 1.38mb large! Am I doing something wrong?
Aug 23, 2008 at 3:17 PM
This is a sample-file, maybe it helps you to find out what's going wrong:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
 "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
 <!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
]>
<!-- Generated by Graphviz version 2.18 (Mon Mar 10 23:30:13 UTC 2008)
     For user: hendrik -->
<!-- Title: G Pages: 1 -->
<svg width="683pt" height="604pt"
 viewBox="0.00 0.00 683.00 604.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 600)">
<title>G</title>
<polygon style="fill:white;stroke:white;" points="-4,4 -4,-600 679,-600 679,4 -4,4"/>
<!-- 0 -->
<g id="node1" class="node"><title>0</title>
<ellipse style="fill:#add8e6;stroke:black;" cx="374" cy="-338" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="374" y="-333.8" style="font-family:Times New Roman;font-size:14.00;">Test 1</text>
</g>
<!-- 1 -->
<g id="node2" class="node"><title>1</title>
<ellipse style="fill:#ffffe0;stroke:black;" cx="303" cy="-258" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="303" y="-253.8" style="font-family:Times New Roman;font-size:14.00;">Test 2</text>
</g>
<!-- 0&#45;&gt;1 -->
<g id="edge2" class="edge"><title>0&#45;&gt;1</title>
<path style="fill:none;stroke:black;" d="M346,-327C335,-321 322,-313 314,-302 310,-297 308,-292 306,-286"/>
<polygon style="fill:black;stroke:black;" points="309.393,-285.119 304,-276 302.529,-286.492 309.393,-285.119"/>
<text text-anchor="middle" x="337" y="-295.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 3 -->
<g id="node4" class="node"><title>3</title>
<ellipse style="fill:#add8e6;stroke:black;" cx="215" cy="-258" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="215" y="-253.8" style="font-family:Times New Roman;font-size:14.00;">Test 4</text>
</g>
<!-- 0&#45;&gt;3 -->
<g id="edge4" class="edge"><title>0&#45;&gt;3</title>
<path style="fill:none;stroke:black;" d="M347,-326C342,-324 336,-322 330,-320 299,-309 287,-318 259,-302 250,-297 242,-290 235,-282"/>
<polygon style="fill:black;stroke:black;" points="237.546,-279.596 228,-275 232.596,-284.546 237.546,-279.596"/>
<text text-anchor="middle" x="285" y="-295.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 4 -->
<g id="node5" class="node"><title>4</title>
<ellipse style="fill:#add8e6;stroke:black;" cx="315" cy="-178" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="315" y="-173.8" style="font-family:Times New Roman;font-size:14.00;">Test 5</text>
</g>
<!-- 0&#45;&gt;4 -->
<g id="edge6" class="edge"><title>0&#45;&gt;4</title>
<path style="fill:none;stroke:black;" d="M370,-320C366,-300 357,-267 347,-240 342,-228 336,-215 330,-204"/>
<polygon style="fill:black;stroke:black;" points="332.916,-202.042 325,-195 326.797,-205.441 332.916,-202.042"/>
<text text-anchor="middle" x="381" y="-255.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 7 -->
<g id="node8" class="node"><title>7</title>
<ellipse style="fill:#add8e6;stroke:black;" cx="477" cy="-98" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="477" y="-93.8" style="font-family:Times New Roman;font-size:14.00;">Test 8</text>
</g>
<!-- 0&#45;&gt;7 -->
<g id="edge8" class="edge"><title>0&#45;&gt;7</title>
<path style="fill:none;stroke:black;" d="M384,-321C391,-308 400,-291 408,-276 432,-224 455,-161 468,-126"/>
<polygon style="fill:black;stroke:black;" points="471.479,-126.584 471,-116 464.774,-124.573 471.479,-126.584"/>
<text text-anchor="middle" x="455" y="-215.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 2 -->
<g id="node3" class="node"><title>2</title>
<ellipse style="fill:#ffffe0;stroke:black;" cx="175" cy="-338" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="175" y="-333.8" style="font-family:Times New Roman;font-size:14.00;">Test 3</text>
</g>
<!-- 2&#45;&gt;3 -->
<g id="edge10" class="edge"><title>2&#45;&gt;3</title>
<path style="fill:none;stroke:black;" d="M172,-320C171,-311 172,-302 176,-294 179,-288 182,-284 186,-279"/>
<polygon style="fill:black;stroke:black;" points="188.404,-281.546 193,-272 183.454,-276.596 188.404,-281.546"/>
<text text-anchor="middle" x="199" y="-295.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 3&#45;&gt;4 -->
<g id="edge12" class="edge"><title>3&#45;&gt;4</title>
<path style="fill:none;stroke:black;" d="M234,-243C249,-230 271,-213 288,-199"/>
<polygon style="fill:black;stroke:black;" points="290.1,-201.8 296,-193 285.9,-196.2 290.1,-201.8"/>
<text text-anchor="middle" x="290" y="-215.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 5 -->
<g id="node6" class="node"><title>5</title>
<ellipse style="fill:#ffffe0;stroke:black;" cx="315" cy="-98" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="315" y="-93.8" style="font-family:Times New Roman;font-size:14.00;">Test 6</text>
</g>
<!-- 4&#45;&gt;5 -->
<g id="edge14" class="edge"><title>4&#45;&gt;5</title>
<path style="fill:none;stroke:black;" d="M315,-160C315,-150 315,-137 315,-126"/>
<polygon style="fill:black;stroke:black;" points="318.5,-126 315,-116 311.5,-126 318.5,-126"/>
<text text-anchor="middle" x="338" y="-135.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 4&#45;&gt;7 -->
<g id="edge16" class="edge"><title>4&#45;&gt;7</title>
<path style="fill:none;stroke:black;" d="M336,-163C350,-154 369,-142 387,-134 403,-126 422,-118 438,-112"/>
<polygon style="fill:black;stroke:black;" points="439.283,-115.26 447,-108 436.44,-108.863 439.283,-115.26"/>
<text text-anchor="middle" x="410" y="-135.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 6 -->
<g id="node7" class="node"><title>6</title>
<ellipse style="fill:#ffffe0;stroke:black;" cx="315" cy="-18" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="315" y="-13.8" style="font-family:Times New Roman;font-size:14.00;">Test 7</text>
</g>
<!-- 5&#45;&gt;6 -->
<g id="edge18" class="edge"><title>5&#45;&gt;6</title>
<path style="fill:none;stroke:black;" d="M295,-83C289,-77 283,-70 280,-62 276,-54 280,-46 285,-39"/>
<polygon style="fill:black;stroke:black;" points="287.404,-41.546 292,-32 282.454,-36.5962 287.404,-41.546"/>
<text text-anchor="middle" x="305" y="-55.9" style="font-family:Courier New;font-size:7.00;">association?</text>
</g>
<!-- 6&#45;&gt;5 -->
<g id="edge20" class="edge"><title>6&#45;&gt;5</title>
<path style="fill:none;stroke:black;" d="M324,-36C326,-41 329,-48 330,-54 331,-60 331,-66 329,-71"/>
<polygon style="fill:black;stroke:black;" points="325.464,-70.4153 325,-81 331.964,-73.0151 325.464,-70.4153"/>
<text text-anchor="middle" x="353" y="-55.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 8 -->
<g id="node9" class="node"><title>8</title>
<ellipse style="fill:#ffffe0;stroke:black;" cx="301" cy="-418" rx="34.9046" ry="18"/>
<text text-anchor="middle" x="301" y="-413.8" style="font-family:Times New Roman;font-size:14.00;">Test 9</text>
</g>
<!-- 8&#45;&gt;0 -->
<g id="edge22" class="edge"><title>8&#45;&gt;0</title>
<path style="fill:none;stroke:black;" d="M318,-402C324,-396 332,-389 338,-382 344,-376 349,-369 354,-363"/>
<polygon style="fill:black;stroke:black;" points="357.049,-364.831 361,-355 351.781,-360.221 357.049,-364.831"/>
<text text-anchor="middle" x="364" y="-375.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 8&#45;&gt;4 -->
<g id="edge24" class="edge"><title>8&#45;&gt;4</title>
<path style="fill:none;stroke:black;" d="M266,-415C227,-410 164,-396 131,-356 113,-334 111,-319 122,-294 146,-231 223,-201 272,-188"/>
<polygon style="fill:black;stroke:black;" points="273.427,-191.226 282,-185 271.416,-184.521 273.427,-191.226"/>
<text text-anchor="middle" x="145" y="-295.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 9 -->
<g id="node10" class="node"><title>9</title>
<ellipse style="fill:#add8e6;stroke:black;" cx="39" cy="-338" rx="39.2301" ry="18"/>
<text text-anchor="middle" x="39" y="-333.8" style="font-family:Times New Roman;font-size:14.00;">Test 10</text>
</g>
<!-- 8&#45;&gt;9 -->
<g id="edge26" class="edge"><title>8&#45;&gt;9</title>
<path style="fill:none;stroke:black;" d="M266,-415C200,-410 62,-397 46,-382 42,-378 39,-372 38,-366"/>
<polygon style="fill:black;stroke:black;" points="41.4778,-365.602 37,-356 34.5125,-366.299 41.4778,-365.602"/>
<text text-anchor="middle" x="75" y="-375.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 10 -->
<g id="node11" class="node"><title>10</title>
<ellipse style="fill:#ffffe0;stroke:black;" cx="282" cy="-338" rx="39.2301" ry="18"/>
<text text-anchor="middle" x="282" y="-333.8" style="font-family:Times New Roman;font-size:14.00;">Test 11</text>
</g>
<!-- 8&#45;&gt;10 -->
<g id="edge28" class="edge"><title>8&#45;&gt;10</title>
<path style="fill:none;stroke:black;" d="M296,-400C295,-394 293,-388 292,-382 291,-377 290,-371 288,-366"/>
<polygon style="fill:black;stroke:black;" points="291.393,-365.119 286,-356 284.529,-366.492 291.393,-365.119"/>
<text text-anchor="middle" x="315" y="-375.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 11 -->
<g id="node12" class="node"><title>11</title>
<ellipse style="fill:#ffffe0;stroke:black;" cx="461" cy="-498" rx="39.2301" ry="18"/>
<text text-anchor="middle" x="461" y="-493.8" style="font-family:Times New Roman;font-size:14.00;">Test 12</text>
</g>
<!-- 11&#45;&gt;0 -->
<g id="edge30" class="edge"><title>11&#45;&gt;0</title>
<path style="fill:none;stroke:black;" d="M451,-480C436,-453 406,-397 388,-364"/>
<polygon style="fill:black;stroke:black;" points="390.916,-362.042 383,-355 384.797,-365.441 390.916,-362.042"/>
<text text-anchor="middle" x="449" y="-415.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 11&#45;&gt;7 -->
<g id="edge34" class="edge"><title>11&#45;&gt;7</title>
<path style="fill:none;stroke:black;" d="M466,-480C470,-468 474,-451 476,-436 490,-322 483,-185 480,-126"/>
<polygon style="fill:black;stroke:black;" points="483.478,-125.602 479,-116 476.512,-126.299 483.478,-125.602"/>
<text text-anchor="middle" x="506" y="-295.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 11&#45;&gt;8 -->
<g id="edge32" class="edge"><title>11&#45;&gt;8</title>
<path style="fill:none;stroke:black;" d="M428,-488C409,-482 385,-473 365,-462 352,-456 339,-447 328,-439"/>
<polygon style="fill:black;stroke:black;" points="330.1,-436.2 320,-433 325.9,-441.8 330.1,-436.2"/>
<text text-anchor="middle" x="391" y="-455.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 12 -->
<g id="node13" class="node"><title>12</title>
<ellipse style="fill:#ffffe0;stroke:black;" cx="629" cy="-498" rx="39.2301" ry="18"/>
<text text-anchor="middle" x="629" y="-493.8" style="font-family:Times New Roman;font-size:14.00;">Test 13</text>
</g>
<!-- 13 -->
<g id="node14" class="node"><title>13</title>
<ellipse style="fill:#add8e6;stroke:black;" cx="629" cy="-418" rx="39.2301" ry="18"/>
<text text-anchor="middle" x="629" y="-413.8" style="font-family:Times New Roman;font-size:14.00;">Test 14</text>
</g>
<!-- 12&#45;&gt;13 -->
<g id="edge36" class="edge"><title>12&#45;&gt;13</title>
<path style="fill:none;stroke:black;" d="M629,-480C629,-470 629,-457 629,-446"/>
<polygon style="fill:black;stroke:black;" points="632.5,-446 629,-436 625.5,-446 632.5,-446"/>
<text text-anchor="middle" x="652" y="-455.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 14 -->
<g id="node15" class="node"><title>14</title>
<ellipse style="fill:#add8e6;stroke:black;" cx="521" cy="-578" rx="39.2301" ry="18"/>
<text text-anchor="middle" x="521" y="-573.8" style="font-family:Times New Roman;font-size:14.00;">Test 15</text>
</g>
<!-- 14&#45;&gt;7 -->
<g id="edge40" class="edge"><title>14&#45;&gt;7</title>
<path style="fill:none;stroke:black;" d="M535,-561C547,-546 562,-521 562,-498 562,-498 562,-498 562,-178 562,-150 536,-128 513,-115"/>
<polygon style="fill:black;stroke:black;" points="514.441,-111.797 504,-110 511.042,-117.916 514.441,-111.797"/>
<text text-anchor="middle" x="585" y="-335.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 14&#45;&gt;8 -->
<g id="edge42" class="edge"><title>14&#45;&gt;8</title>
<path style="fill:none;stroke:black;" d="M486,-570C452,-561 402,-544 367,-516 344,-496 325,-466 314,-445"/>
<polygon style="fill:black;stroke:black;" points="316.916,-443.042 309,-436 310.797,-446.441 316.916,-443.042"/>
<text text-anchor="middle" x="390" y="-495.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 14&#45;&gt;11 -->
<g id="edge44" class="edge"><title>14&#45;&gt;11</title>
<path style="fill:none;stroke:black;" d="M508,-561C500,-550 489,-535 480,-523"/>
<polygon style="fill:black;stroke:black;" points="482.8,-520.9 474,-515 477.2,-525.1 482.8,-520.9"/>
<text text-anchor="middle" x="517" y="-535.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
<!-- 14&#45;&gt;12 -->
<g id="edge38" class="edge"><title>14&#45;&gt;12</title>
<path style="fill:none;stroke:black;" d="M544,-563C554,-557 566,-549 576,-542 584,-535 594,-528 602,-521"/>
<polygon style="fill:black;stroke:black;" points="604.779,-523.219 610,-514 600.169,-517.951 604.779,-523.219"/>
<text text-anchor="middle" x="605" y="-535.9" style="font-family:Courier New;font-size:7.00;">association</text>
</g>
</g>
</svg>



Developer
Jan 23, 2009 at 12:14 AM
Hi Herjann,

I presume this answer is waaay too late to be of any value to you, but in case it helps others facing the same problem :

I put your sample input through the converter and puzzled over it for five or ten minutes, until it suddenly dawned on me :

The reason the output XAML is so huge is that the text has been converted into "paths", which is a technical process that ensures that the XAML will work properly even on computers that don't have the specific font installed, but unfortunately this same process also bloats the XAML and makes it difficult to ever edit the text again.

In short, it is an issue.

There is another discussion about exactly this issue :

http://www.codeplex.com/XamlTune/Thread/View.aspx?ThreadId=43479

I am not aware of any plans by anyone to fix this behaviour - but that's the point of open source - if it's important to you, please contribute.

I've recently started contributing to this project (my first ever open source contributions) simply because I have encountered issues that have affected one of my clients, and I've had to fix the issues anyway for the sake of my client, and so I've also contributed the changes back here to the central repository.

Open source is what you and I turn it into.  Encourage others to use and contribute to XamlTune, and we might finally end up with a flawless SVG -> XAML converter.

In the meantime, we are both inconvenienced by the present limitations.  Se la vive.  :)


Nov 5, 2009 at 4:00 PM

I have developed a solution @ http://www.sixpairs.com

There is also an online tool there.

More info: http://sixpairs.spaces.live.com/