annotate svgparsetest.pl @ 75:874a6a2c28cf laserkard

session with nick. redisigned faq page
author Robert McIntyre <rlm@mit.edu>
date Tue, 29 Jun 2010 15:36:30 -0400
parents 07c19a58ba5a
children
rev   line source
rlm@37 1 #!/usr/bin/perl
rlm@37 2
rlm@37 3 # use module
rlm@37 4 use XML::Simple;
rlm@37 5 use Data::Dumper;
rlm@37 6 $xml = new XML::Simple;
rlm@37 7
rlm@37 8
rlm@37 9 $sss = <<HERE;
rlm@37 10
rlm@38 11 <svg height="318" width="515" version="1.1" xmlns="http://www.w3.org/2000/svg"><desc>Created with Raphaƫl</desc><defs></defs><rect stroke="#0000ff" fill="none" ry="40" rx="40" r="40" height="317" width="514" y="0.5" x="0.5"></rect><path transform="" d="M44.912499999999994,137.83750000000003C44.912499999999994,129.43750000000003,34.93749999999999,131.88750000000005,27.237499999999994,131.53750000000002L27.237499999999994,144.13750000000002C34.93749999999999,143.78750000000002,44.912499999999994,146.41250000000002,44.912499999999994,137.8375ZM46.31249999999999,168.81250000000003C43.86249999999999,162.33750000000003,47.012499999999996,151.31250000000003,37.21249999999999,151.31250000000003L27.23749999999999,151.31250000000003L27.23749999999999,168.81250000000003L17.43749999999999,168.81250000000003L17.43749999999999,123.83750000000003L41.58749999999999,123.83750000000003C55.58749999999999,122.43750000000003,59.43749999999999,143.43750000000003,47.71249999999999,147.46250000000003C55.93749999999999,149.21250000000003,52.96249999999999,161.98750000000004,56.11249999999999,168.81250000000003L46.312499999999986,168.81250000000003Z" stroke="#ff0000" fill="none"></path><path transform="" d="M77.63749999999999,142.0375C71.86249999999998,142.0375,69.76249999999999,146.5875,69.76249999999999,152.5375C69.76249999999999,158.48749999999998,71.86249999999998,163.0375,77.63749999999999,163.0375C83.4125,163.0375,85.51249999999999,158.48749999999998,85.51249999999999,152.5375C85.51249999999999,146.5875,83.4125,142.0375,77.63749999999999,142.0375ZM77.63749999999999,169.6875C66.7875,169.6875,60.83749999999999,163.2125,60.83749999999999,152.5375C60.83749999999999,141.86249999999998,66.7875,135.3875,77.63749999999999,135.3875C88.48749999999998,135.3875,94.43749999999999,141.86249999999998,94.43749999999999,152.5375C94.43749999999999,163.2125,88.48749999999998,169.6875,77.63749999999999,169.6875Z" stroke="#ff0000" fill="none"></path><path transform="" d="M116.31250000000006,163.0375C121.91250000000005,163.0375,124.01250000000006,158.1375,124.01250000000006,152.5375C124.01250000000006,146.9375,121.91250000000007,142.0375,116.31250000000006,142.0375C110.71250000000006,142.0375,108.78750000000005,146.5875,108.78750000000005,152.5375C108.78750000000005,158.3125,110.71250000000005,163.0375,116.31250000000006,163.0375ZM119.46250000000006,169.6875C114.21250000000006,169.6875,110.71250000000006,167.9375,108.61250000000007,164.6125L108.61250000000007,168.8125L100.03750000000007,168.8125L100.03750000000007,123.8375L109.13750000000006,123.8375L109.13750000000006,140.2875C111.06250000000006,137.1375,115.08750000000006,135.3875,119.46250000000006,135.3875C128.56250000000006,135.3875,132.93750000000006,142.73749999999998,132.93750000000006,152.5375C132.93750000000006,162.3375,128.56250000000006,169.6875,119.46250000000006,169.6875Z" stroke="#ff0000" fill="none"></path><path transform="" d="M160.41250000000002,149.0375C160.58750000000003,140.8125,148.16250000000002,139.9375,146.2375,146.9375C146.0625,147.8125,145.88750000000002,148.3375,145.88750000000002,149.0375L160.41250000000002,149.0375ZM145.88750000000002,154.6375C144.66250000000002,164.08749999999998,158.4875,165.3125,160.93750000000003,158.6625L168.81250000000003,158.6625C166.53750000000002,165.6625,161.63750000000002,169.6875,153.41250000000002,169.6875C142.7375,169.6875,137.66250000000002,163.0375,136.78750000000002,152.5375C135.21250000000003,133.2875,165.31250000000003,129.2625,168.63750000000002,147.4625C169.16250000000002,149.7375,169.51250000000002,152.1875,169.3375,154.63750000000002L145.88750000000002,154.63750000000002Z" stroke="#ff0000" fill="none"></path><path transform="" d="M195.41250000000014,143.9625C187.88750000000013,142.38750000000002,183.51250000000013,146.5875,183.51250000000013,154.1125L183.51250000000013,168.8125L174.41250000000014,168.8125L174.41250000000014,136.2625L182.98750000000013,136.2625C183.16250000000014,138.1875,182.63750000000013,140.6375,183.16250000000014,142.21249999999998C184.73750000000013,137.83749999999998,189.63750000000013,134.68749999999997,195.41250000000014,135.73749999999998L195.41250000000014,143.96249999999998Z" stroke="#ff0000" fill="none"></path><path transform="" d="M216.9375,168.8125C209.4125,169.8625,201.3625,169.3375,201.3625,161.4625L201.3625,142.2125L195.9375,142.2125L195.9375,136.26250000000002L201.3625,136.26250000000002L201.3625,126.46250000000002L210.28750000000002,126.46250000000002L210.28750000000002,136.26250000000002L216.93750000000003,136.26250000000002L216.93750000000003,142.2125L210.28750000000002,142.2125L210.28750000000002,158.3125C209.76250000000002,162.6875,213.6125,162.5125,216.93750000000003,161.8125L216.93750000000003,168.8125Z" stroke="#ff0000" fill="none"></path><path transform="" d="M239.51250000000027,123.83749999999998L253.33750000000026,123.83749999999998L264.0125000000003,154.81249999999997L273.9875000000003,123.83749999999998L287.9875000000003,123.83749999999998L287.9875000000003,168.81249999999997L278.7125000000003,168.81249999999997L278.5375000000003,136.96249999999998L267.51250000000033,168.81249999999997L259.81250000000034,168.81249999999997L248.78750000000034,137.31249999999997L248.78750000000034,168.81249999999997L239.51250000000033,168.81249999999997L239.51250000000033,123.83749999999998Z" stroke="#ff0000" fill="none"></path><path transform="" d="M294.63750000000005,153.0625C292.88750000000005,135.9125,316.33750000000003,129.2625,324.9125,142.2125C325.7875,143.7875,326.3125,145.5375,326.4875,147.63750000000002L317.7375,147.63750000000002C317.21250000000003,143.9625,314.9375,142.03750000000002,311.08750000000003,142.03750000000002C300.93750000000006,142.03750000000002,300.93750000000006,162.8625,310.9125,163.03750000000002C315.1125,162.8625,317.38750000000005,160.2375,318.08750000000003,156.38750000000002L326.6625,156.38750000000002C325.6125,164.6125,319.83750000000003,169.68750000000003,311.08750000000003,169.68750000000003C300.76250000000005,169.68750000000003,295.68750000000006,163.21250000000003,294.63750000000005,153.06250000000003Z" stroke="#ff0000" fill="none"></path><path transform="" d="M332.6125000000002,123.83749999999998L342.4125000000002,123.83749999999998L342.4125000000002,168.81249999999997L332.6125000000002,168.81249999999997L332.6125000000002,123.83749999999998Z" stroke="#ff0000" fill="none"></path><path transform="" d="M366.0374999999999,142.3875C355.1874999999999,142.3875,360.4374999999999,159.0125,359.2124999999999,168.8125L350.1124999999999,168.8125L350.1124999999999,136.2625L358.6874999999999,136.2625C358.8624999999999,137.6625,358.33749999999986,139.7625,358.8624999999999,140.8125C360.6124999999999,137.4875,364.2874999999999,135.7375,368.8374999999999,135.3875C385.1124999999999,134.5125,379.8624999999999,154.2875,380.7374999999999,168.8125L371.8124999999999,168.8125L371.8124999999999,150.4375C371.8124999999999,145.5375,370.7624999999999,142.2125,366.0374999999999,142.3875Z" stroke="#ff0000" fill="none"></path><path transform="" d="M405.4124999999997,168.8125C397.8874999999997,169.8625,389.8374999999997,169.3375,389.8374999999997,161.4625L389.8374999999997,142.2125L384.4124999999997,142.2125L384.4124999999997,136.26250000000002L389.8374999999997,136.26250000000002L389.8374999999997,126.46250000000002L398.7624999999997,126.46250000000002L398.7624999999997,136.26250000000002L405.4124999999997,136.26250000000002L405.4124999999997,142.2125L398.7624999999997,142.2125L398.7624999999997,158.3125C398.2374999999997,162.6875,402.0874999999997,162.5125,405.4124999999997,161.8125L405.4124999999997,168.8125Z" stroke="#ff0000" fill="none"></path><path transform="" d="M408.9124999999999,172.66250000000002C413.8124999999999,173.71250000000003,419.0624999999999,172.13750000000002,417.13749999999993,166.71250000000003L405.76249999999993,136.26250000000005L415.38749999999993,136.26250000000005L422.73749999999995,158.48750000000004L429.91249999999997,136.26250000000005L439.18749999999994,136.26250000000005L425.53749999999997,172.83750000000003C423.61249999999995,179.48750000000004,417.66249999999997,181.23750000000004,408.91249999999997,180.01250000000005L408.91249999999997,172.66250000000005Z" stroke="#ff0000" fill="none"></path><path transform="" d="M462.9875000000002,143.9625C455.4625000000002,142.38750000000002,451.0875000000002,146.5875,451.0875000000002,154.1125L451.0875000000002,168.8125L441.9875000000002,168.8125L441.9875000000002,136.2625L450.56250000000017,136.2625C450.7375000000002,138.1875,450.21250000000015,140.6375,450.7375000000002,142.21249999999998C452.31250000000017,137.83749999999998,457.2125000000002,134.68749999999997,462.9875000000002,135.73749999999998L462.9875000000002,143.96249999999998Z" stroke="#ff0000" fill="none"></path><path transform="" d="M488.53749999999945,149.0375C488.71249999999947,140.8125,476.28749999999945,139.9375,474.36249999999944,146.9375C474.18749999999943,147.8125,474.0124999999994,148.3375,474.0124999999994,149.0375L488.5374999999994,149.0375ZM474.0124999999995,154.6375C472.78749999999945,164.08749999999998,486.6124999999995,165.3125,489.0624999999995,158.6625L496.9374999999995,158.6625C494.6624999999995,165.6625,489.7624999999995,169.6875,481.5374999999995,169.6875C470.8624999999995,169.6875,465.7874999999995,163.0375,464.9124999999995,152.5375C463.3374999999995,133.2875,493.4374999999995,129.2625,496.76249999999953,147.4625C497.2874999999995,149.7375,497.63749999999953,152.1875,497.4624999999995,154.63750000000002L474.01249999999953,154.63750000000002Z" stroke="#ff0000" fill="none"></path><path transform="" d="M310.86805555555554,267.60416666666663C307.88205555555555,266.97916666666663,306.14605555555556,268.6461666666666,306.14605555555556,271.63216666666665L306.14605555555556,277.4651666666667L302.5350555555556,277.4651666666667L302.5350555555556,264.5481666666667L305.93705555555556,264.5481666666667C306.00705555555555,265.3121666666667,305.7990555555556,266.2851666666667,306.00705555555555,266.9101666666667C306.63205555555555,265.1731666666667,308.57605555555557,263.9231666666667,310.86805555555554,264.34016666666673L310.86805555555554,267.60416666666674Z" stroke="#ff0000" fill="none"></path><path transform="" d="M312.3958333333333,259.61805555555554L315.9378333333333,259.61805555555554L315.9378333333333,277.4650555555555L312.3958333333333,277.4650555555555L312.3958333333333,259.61805555555554Z" stroke="#ff0000" fill="none"></path><path transform="" d="M322.11805555555554,266.2847222222222C323.50705555555555,263.8537222222222,328.7850555555555,263.2987222222222,329.89605555555556,266.3537222222222C330.7290555555556,265.3127222222222,331.9100555555556,264.2017222222222,333.7850555555556,264.2017222222222C340.2430555555556,264.2017222222222,338.2290555555556,271.7707222222222,338.50705555555555,277.4657222222222L334.9650555555556,277.4657222222222L334.89605555555556,268.92372222222224C334.82605555555557,267.67372222222224,334.13205555555555,266.97872222222225,332.81205555555556,266.97872222222225C328.7850555555556,266.97872222222225,331.00705555555555,273.71572222222227,330.45105555555557,277.46572222222227L326.9100555555556,277.46572222222227L326.8400555555556,269.06272222222225C326.77105555555556,267.74272222222226,326.2150555555556,266.90972222222223,324.75705555555555,266.97872222222225C320.86805555555554,267.25672222222227,322.74305555555554,273.6457222222222,322.32605555555557,277.46572222222227L318.7850555555556,277.46572222222227L318.7850555555556,264.5487222222223L322.1180555555556,264.5487222222223L322.1180555555556,266.2847222222223Z" stroke="#ff0000" fill="none"></path><path transform="" d="M344.6875000000002,269.8263888888889C344.20150000000024,265.10438888888893,350.3125000000002,261.14538888888893,353.09050000000025,265.1733888888889L353.4375000000002,263.8543888888889L355.52050000000025,263.8543888888889L353.71550000000025,271.3543888888889C353.71550000000025,271.5623888888889,353.85450000000026,271.9793888888889,354.13150000000024,271.9093888888889C356.28450000000026,271.70138888888886,357.11850000000027,269.6183888888889,357.11850000000027,267.32638888888886C357.11850000000027,263.36838888888883,354.47950000000026,261.1453888888889,350.3125000000003,261.21538888888887C345.7985000000003,261.2843888888889,343.2985000000003,264.06238888888885,343.2985000000003,268.57638888888886C343.2985000000003,273.2293888888889,346.0065000000003,275.7293888888889,350.65950000000026,275.86838888888883C352.88150000000024,275.93738888888885,354.89550000000025,275.0343888888888,356.00650000000024,273.8543888888888L358.09050000000025,273.8543888888888C356.5625000000002,276.2153888888888,354.0625000000002,277.88238888888884,350.52050000000025,277.88238888888884C344.75650000000024,277.88238888888884,340.86850000000027,274.2703888888888,340.86850000000027,268.50738888888884C340.86850000000027,262.88238888888884,344.6875000000003,259.20138888888886,350.38150000000024,259.20138888888886C355.24350000000027,259.20138888888886,359.0625000000002,261.84038888888887,359.0625000000002,266.84038888888887C359.0625000000002,270.93738888888885,356.63150000000024,273.57638888888886,353.1595000000002,274.06238888888885C352.1185000000002,274.20138888888886,351.4935000000002,273.36838888888883,351.2845000000002,272.67338888888884C349.4095000000002,275.5903888888888,344.2705000000002,273.43738888888885,344.6875000000002,269.82638888888886ZM350.3125000000002,265.7983888888889C347.32650000000024,265.7983888888889,345.7985000000002,271.7013888888889,349.20150000000024,271.7013888888889C351.14550000000025,271.7013888888889,352.1185000000002,269.9653888888889,352.25650000000024,267.9513888888889C352.25650000000024,266.77038888888893,351.4235000000002,265.7983888888889,350.3125000000002,265.7983888888889Z" stroke="#ff0000" fill="none"></path><path transform="" d="M364.75694444444434,266.2847222222222C366.14594444444435,263.8537222222222,371.4239444444443,263.2987222222222,372.53494444444436,266.3537222222222C373.3679444444444,265.3127222222222,374.5489444444444,264.2017222222222,376.4239444444444,264.2017222222222C382.8819444444444,264.2017222222222,380.8679444444444,271.7707222222222,381.14594444444435,277.4657222222222L377.6039444444444,277.4657222222222L377.53494444444436,268.92372222222224C377.46494444444437,267.67372222222224,376.77094444444435,266.97872222222225,375.45094444444436,266.97872222222225C371.4239444444444,266.97872222222225,373.64594444444435,273.71572222222227,373.08994444444437,277.46572222222227L369.5489444444444,277.46572222222227L369.4789444444444,269.06272222222225C369.40994444444436,267.74272222222226,368.8539444444444,266.90972222222223,367.39594444444435,266.97872222222225C363.50694444444434,267.25672222222227,365.38194444444434,273.6457222222222,364.96494444444437,277.46572222222227L361.4239444444444,277.46572222222227L361.4239444444444,264.5487222222223L364.7569444444444,264.5487222222223L364.7569444444444,266.2847222222223Z" stroke="#ff0000" fill="none"></path><path transform="" d="M387.6041666666665,262.53472222222223L384.06216666666654,262.53472222222223L384.06216666666654,259.61772222222226L387.6041666666665,259.61772222222226L387.6041666666665,262.53472222222223ZM384.06216666666654,264.54872222222224L387.6041666666665,264.54872222222224L387.6041666666665,277.4657222222222L384.06216666666654,277.4657222222222L384.06216666666654,264.54872222222224Z" stroke="#ff0000" fill="none"></path><path transform="" d="M397.4652777777778,277.46527777777777C394.47927777777784,277.88227777777774,391.28427777777785,277.6732777777778,391.28427777777785,274.5482777777778L391.28427777777785,266.9092777777778L389.13227777777786,266.9092777777778L389.13227777777786,264.5482777777778L391.28427777777785,264.5482777777778L391.28427777777785,260.6592777777778L394.8262777777778,260.6592777777778L394.8262777777778,264.5482777777778L397.4652777777778,264.5482777777778L397.4652777777778,266.9092777777778L394.8262777777778,266.9092777777778L394.8262777777778,273.2982777777778C394.6182777777778,275.0342777777778,396.1462777777778,274.96527777777777,397.4652777777778,274.6872777777778L397.4652777777778,277.4652777777778Z" stroke="#ff0000" fill="none"></path><path transform="" d="M399.2708333333335,273.64583333333337L403.1598333333335,273.64583333333337L403.1598333333335,277.4648333333334L399.2708333333335,277.4648333333334L399.2708333333335,273.64583333333337Z" stroke="#ff0000" fill="none"></path><path transform="" d="M414.75694444444434,269.61805555555554C414.82594444444436,266.35405555555553,409.89594444444435,266.00705555555555,409.13194444444434,268.7850555555555C409.0629444444443,269.1320555555555,408.99294444444433,269.3400555555555,408.99294444444433,269.61805555555554L414.75694444444434,269.61805555555554ZM408.99294444444433,271.8400555555555C408.50694444444434,275.5900555555555,413.99294444444433,276.0760555555555,414.9649444444443,273.4370555555555L418.0899444444443,273.4370555555555C417.1879444444443,276.2150555555555,415.24294444444433,277.8120555555555,411.9789444444443,277.8120555555555C407.74294444444433,277.8120555555555,405.7289444444443,275.1740555555555,405.38194444444434,271.0070555555555C404.75694444444434,263.3680555555555,416.70094444444436,261.7710555555555,418.02094444444435,268.9930555555555C418.2289444444444,269.8960555555555,418.36794444444433,270.8680555555555,418.2989444444444,271.84005555555547L408.9929444444444,271.84005555555547Z" stroke="#ff0000" fill="none"></path><path transform="" d="M426.49305555555543,275.1736111111111C428.7850555555554,275.1736111111111,429.5490555555554,273.22961111111107,429.5490555555554,270.9376111111111C429.5490555555554,268.7156111111111,428.7850555555554,266.8406111111111,426.49305555555543,266.8406111111111C424.20105555555546,266.8406111111111,423.36805555555543,268.6456111111111,423.36805555555543,271.0066111111111C423.36805555555543,273.3676111111111,424.27105555555545,275.1736111111111,426.49305555555543,275.1736111111111ZM425.52105555555545,264.2016111111111C427.25705555555544,264.1316111111111,428.57605555555546,265.1736111111111,429.41005555555546,266.1456111111111L429.41005555555546,259.6176111111111L432.95105555555546,259.6176111111111L432.95105555555546,277.4656111111111L429.54905555555547,277.4656111111111L429.54905555555547,275.79861111111114C428.78505555555546,277.04861111111114,427.46505555555547,277.81261111111115,425.59005555555547,277.81261111111115C421.56205555555545,277.74261111111116,419.82605555555546,274.82661111111116,419.82605555555546,270.86761111111116C419.82605555555546,267.04861111111114,421.63205555555544,264.3406111111112,425.52105555555545,264.20161111111116Z" stroke="#ff0000" fill="none"></path><path transform="" d="M441.3541666666665,275.03472222222223C445.7291666666665,275.03472222222223,443.6461666666665,268.5067222222222,444.13216666666654,264.54872222222224L447.67316666666653,264.54872222222224L447.67316666666653,277.4657222222222L444.27116666666655,277.4657222222222C444.20116666666655,276.90972222222223,444.41016666666656,276.0767222222222,444.20116666666655,275.65972222222223C443.43716666666654,276.97872222222225,441.9791666666666,277.74272222222226,440.2431666666665,277.81272222222225C433.8541666666665,278.15972222222223,435.79816666666653,270.31272222222225,435.52116666666655,264.54872222222224L439.13216666666654,264.54872222222224L439.13216666666654,271.8407222222222C439.13216666666654,273.78472222222223,439.54816666666653,275.03472222222223,441.3541666666665,275.03472222222223Z" stroke="#ff0000" fill="none"></path><path d="M0.5,269.5L270.5,269.5" stroke="#ff0000" fill="none"></path></svg>
rlm@37 12
rlm@37 13
rlm@37 14 HERE
rlm@37 15
rlm@37 16
rlm@37 17 # read XML file
rlm@37 18 $data = $xml->XMLin($sss, ForceArray => 1);
rlm@37 19
rlm@37 20
rlm@37 21 my %data = %$data;
rlm@37 22
rlm@37 23 my %juzz =
rlm@37 24 (
rlm@37 25
rlm@37 26 path => $data{'path'},
rlm@37 27 rect => $data{'rect'},
rlm@37 28 width =>"16in" ,
rlm@37 29 height =>"12in" ,
rlm@37 30 version =>"1.1",
rlm@37 31 xmlns =>"http://www.w3.org/2000/svg"
rlm@37 32
rlm@37 33 );
rlm@37 34
rlm@37 35
rlm@37 36 $out = $xml->XMLout(\%juzz , RootName=>'svg');
rlm@37 37
rlm@37 38
rlm@37 39 my $fixed = <<HERE;
rlm@37 40 <?xml version="1.0" standalone="no"?>
rlm@37 41 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
rlm@37 42 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
rlm@37 43 HERE
rlm@37 44
rlm@37 45
rlm@37 46
rlm@37 47 $fixed .= $out;
rlm@37 48
rlm@37 49 print $fixed;
rlm@37 50
rlm@38 51 ############### send to file
rlm@38 52
rlm@38 53 open OUT, ">/home/rlm/Desktop/perlOut.svg";
rlm@38 54 select OUT;
rlm@38 55 print $fixed;
rlm@38 56 close OUT;
rlm@38 57
rlm@38 58
rlm@38 59
rlm@38 60
rlm@38 61
rlm@38 62