包含SVG和基于浏览器的VML的XML

XML containing SVG and VML based on the browser

本文关键字:VML XML 浏览器 SVG 包含      更新时间:2023-09-26

我使用Fusion Chart与"纯JAVASCRIPT",但与导出功能,我们想在客户端。所以FusionChart在客户端提供图表的SVG或VML。我们希望将这个VML或SVG合并为XML文件和XSLT样式表。因此,到目前为止,我们希望在我们的应用程序中提供导出到XML的功能。

现在的问题是SVG只被Mozilla,chrome和IE理解,它给了VML。因此客户端将得到包含SVG和VML的通用文件,但问题是XSLT中没有检测浏览器类型和版本的意思。我已经使用IE条件注释,但它不工作在chrome,mozilla和不工作在IE。即使javascript不工作,我将希望javascript变量值在XSLT变量,这将是不可行的,因为XML首先呈现在javascript之前,所以我不能有所有浏览器的通用XML+XSLT代码。因为我们想为包含data + image的客户端提供独立的XML。

任何关于这方面的帮助将不胜感激。

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="#stylesheet"?>
<!DOCTYPE doc [
<!ATTLIST xsl:stylesheet id ID #REQUIRED>]>
<doc>
<xsl:stylesheet id="stylesheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="xsl:stylesheet" />
 <xsl:template match="/doc">
<html>
<head>
 <style>
  body{
  font-family: Arial, Verdana,Helvetica, sans-serif;
  }
  table{
  font-size: 11px;
  }
 th{
 background-color:#D1D2D4;
 }
 </style>
</head>
<body>
<br />
   <!-- detect browser here for getting SVG or VML if Mozilla,chrome then SVG->
<svg xmlns="http://www.w3.org/2000/svg"........> </svg>
 <!-- If IE <=8 then VML -->
 <br/>
 <table border="2" cellspacing="1" width="86%">
  <tr>
   <th>Category</th>
   <th>Hits</th>
   <th>Bytes</th>
   </tr>
  <tr>
   <td>IPAddress</td>
   <td>1818</td>
   <td>747.32 MB</td>
   </tr>
   <tr>
   <td>None</td>
   <td>1523</td>
   <td>27.82 MB</td>
   </tr>
 </table>
  </body>
 </html>
</xsl:template>
</xsl:stylesheet>
 </doc>

谢谢,亚莎Koshti

您可以使用API - chart.getSVGString()获得SVG作为字符串(在IE6+或任何浏览器中)。这有帮助吗?