lewisje / svgweb

Automatically exported from code.google.com/p/svgweb
Other
0 stars 0 forks source link

svg: prefix not supported #454

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When testing graph2svg resulting svg documents after an XSLT 2.0
transformation, it appears that the svg: prefix is not supported by SVGWeb.

I have build another demo page with those resulting files only and they are
successfully displayed by the browser native renderer of FireFox. After
removing manually the svg: prefix, the files are also renderer by the Flash
object.

What do you think ?

Thanks!

-Alain

Original issue reported on code.google.com by alain.co...@gmail.com on 17 Feb 2010 at 4:51

GoogleCodeExporter commented 8 years ago
Proposed fixes:

@@ -1570,14 +1570,16 @@
       // bottleneck; see Issue 218
       // for details: http://code.google.com/p/svgweb/issues/detail?id=218
       if (svg.indexOf(':svg ') == -1) { // was regular expression
-        if (/xmlns\=['"]http:\/\/www\.w3\.org\/2000\/svg['"]/.test(svg) == 
false) {
-          svg = svg.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg"');
+        if 
(/xmlns(:[\w]+)?\=['"]http:\/\/www\.w3\.org\/2000\/svg['"]/.test(svg) ==
false) {
+          svg = svg.replace(/<svg([\s\/])/, '<svg
xmlns="http://www.w3.org/2000/svg"$1');
+          svg = svg.replace(/<([\w]+):svg([\s\/])/, '<$1:svg
xmlns:$1="http://www.w3.org/2000/svg"$2');
         }
       }

       // add xlink namespace if it is not present
       if (/xmlns:[^=]+=['"]http:\/\/www\.w3\.org\/1999\/xlink['"]/.test(svg) == false) {
-        svg = svg.replace('<svg', '<svg 
xmlns:xlink="http://www.w3.org/1999/xlink"');
+        svg = svg.replace(/<svg([\s\/])/, '<svg
xmlns:xlink="http://www.w3.org/1999/xlink"$1');
+        svg = svg.replace(/<([\w]+):svg([\s\/])/, '<$1:svg
xmlns:xlink="http://www.w3.org/1999/xlink"$2');
       }
     }

@@ -1638,14 +1640,14 @@
       // incorrectly think these are SVG root elements. To do this, temporarily
       // rename the SVG root element, then rename nested <svg> root elements
       // to a temporary token that we will restore at the end of this method
-      svg = svg.replace(/<(svg:)?svg/, '<$1SVGROOT'); // root <svg> element
-      svg = svg.replace(/<(svg:)?svg/g, '<$1NESTEDSVG'); // nested <svg>
-      svg = svg.replace(/<(svg:)?SVGROOT/, '<$1svg');
+      svg = svg.replace(/<([\w]+:)?svg([\s\/])/, '<$1SVGROOT$2'); // root 
<svg> element
+      svg = svg.replace(/<([\w]+:)?svg([\s\/])/g, '<$1NESTEDSVG$2'); // nested 
<svg>
+      svg = svg.replace(/<([\w]+:)?SVGROOT([\s\/])/, '<$1svg$2');

       // break SVG string into pieces so that we don't incorrectly add our
       // <__text> fake text nodes outside the SVG root tag
-      var separator = svg.match(/<[a-zA-Z_-]*:?svg/)[0];
-      var pieces = svg.split(/<[a-zA-Z_-]*:?svg/);
+      var separator = svg.match(/<[a-zA-Z_-]*:?svg[\s\/]/)[0];
+      var pieces = svg.split(/<[a-zA-Z_-]*:?svg[\s\/]/);

       // extract CDATA sections temporarily so that we don't end up
       // adding double <__text> blocks
@@ -1697,7 +1699,7 @@

     // earlier we turned nested <svg> elements into a temporary token; restore
     // them
-    svg = svg.replace(/<(svg:)?NESTEDSVG/g, '<$1svg');
+    svg = svg.replace(/<([\w]+:)?NESTEDSVG/g, '<$1svg');

     if (this.renderer == FlashHandler) {
       // handle Flash encoding issues

-Alain

Original comment by alain.co...@gmail.com on 18 Feb 2010 at 10:51

GoogleCodeExporter commented 8 years ago

Original comment by bradneub...@gmail.com on 18 Feb 2010 at 6:21

GoogleCodeExporter commented 8 years ago
We've dropped support for custom prefixing in Issue 332. Thanks for the patch 
though!

Original comment by bradneub...@gmail.com on 8 Apr 2010 at 3:50