title: Replace xlinks to inline in SVG using XSLT
body: <p>I need to replace all <strong>xlink</strong> usages to simple inline xml in SVG and afterwards delete "<strong>defs</strong>" section and remove all the <strong>boo</strong>: attributes. This one is needed because SVG viewer which is intended to to be used does not support xlinks.</p>
  
  <p>Initial simplified XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;svg xmlns="http://www.w3.org/2000/svg"&gt;
      &lt;boo:metadata&gt;
      &lt;boo:text line-space="1.5" minimum-size="15" regular-size="20"/&gt;
      &lt;/boo:metadata&gt;
      &lt;g transform="translate(149,60)"&gt;
          &lt;rect x="0" y="0" fill-opacity="0.6" width="579" height="150"/&gt;
              &lt;defs&gt;&lt;!-- huge section  with predefined items--&gt;
                  &lt;g id="ne"&gt;
                      &lt;path id="ne..."/&gt;
                  &lt;/g&gt;
                  &lt;g id="nw"&gt;
                      &lt;path id="nw.."/&gt;
                  &lt;/g&gt;
                  &lt;g id="rt2"&gt;
                      &lt;rect id="RT2" /&gt;
                      &lt;path id="some cool path id"/&gt;
                  &lt;/g&gt;
                  &lt;g id="rt3"&gt;
                      &lt;rect id="rt3sss" rx="2" ry="2"/&gt;
                  &lt;/g&gt;
                  &lt;g boo:type="Icon" id="AIRPORT" boo:replacementWords="FLUGHAFEN"&gt;
                      &lt;rect id="ICON_AIRPORT" fill="#FCFFFF" height="15" width="15"/&gt;
                      &lt;path id="ICON_AIRPORTPATH"/&gt;
                  &lt;/g&gt;
              &lt;/defs&gt;
  
              &lt;g boo:side="R" id="sssss" transform="translate(184,0)"&gt;
                  &lt;g transform="translate(0.000000,0.000000)"&gt;
                      &lt;g boo:style="HorizontalAlignment:Center;VerticalAlignment:Bottom;" transform="translate(63.202000,126.903002)"&gt;   
                          &lt;g transform="translate(0.000000,0.000000)"&gt;
                              &lt;!-- actual usage --&gt;
                              &lt;use xlink:actuate="onLoad" xlink:type="simple" xlink:show="embed" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#NE" boo:style="HorizontalAlignment:Left;"/&gt;
                          &lt;/g&gt;
                          &lt;g transform="translate(23.045999,0.000000)" boo:style="HorizontalAlignment:Left;Margin:0 5 0 5;"&gt;
                              &lt;g transform="translate(0.000000,0.000000)" boo:style="Margin:0 1 0 1;"&gt;
                              &lt;g transform="scale(1.150000,1.1500000)"&gt;
                                  &lt;!-- actual usage --&gt;
                                  &lt;use xlink:actuate="onLoad" xlink:type="simple" xlink:show="embed" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#RT2"/&gt;
                              &lt;/g&gt;
                              &lt;text transform="translate(16,13)" text-anchor="middle"&gt;4&lt;/text&gt;
                          &lt;/g&gt;
                      &lt;/g&gt;
                  &lt;/g&gt;
              &lt;/g&gt;
          &lt;/g&gt;
      &lt;/g&gt;
  &lt;/svg&gt;
  </code></pre>
  
  <p>Expected result</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;svg xmlns="http://www.w3.org/2000/svg"&gt;
      &lt;g transform="translate(149,60)"&gt;
          &lt;rect x="0" y="0" fill-opacity="0.6" width="579" height="150"/&gt;
              &lt;g id="sssss" transform="translate(184,0)"&gt;
                  &lt;g transform="translate(0.000000,0.000000)"&gt;
                      &lt;g transform="translate(63.202000,126.903002)"&gt;   
                          &lt;g transform="translate(0.000000,0.000000)"&gt;
                              &lt;path id="ne..."/&gt;
                          &lt;/g&gt;
                          &lt;g transform="translate(23.045999,0.000000)"&gt;
                              &lt;g transform="translate(0.000000,0.000000)"&gt;
                              &lt;g transform="scale(1.150000,1.1500000)"&gt;                           
                                  &lt;rect id="RT2" /&gt;
                                  &lt;path id="some cool path id"/&gt;
                              &lt;/g&gt;
                              &lt;text transform="translate(16,13)" text-anchor="middle"&gt;4&lt;/text&gt;
                          &lt;/g&gt;
                      &lt;/g&gt;
                  &lt;/g&gt;
              &lt;/g&gt;
          &lt;/g&gt;
      &lt;/g&gt;
  &lt;/svg&gt;
  </code></pre>