很怪事呀,难道只能用dom来访问xml文件来手工创建vml对象吗,不能用一个xslt自动把xml转换成vml图表吗?

解决方案 »

  1.   

    可以直接用XSLT呀
    怎么用DOM,多此一举哟<?xml version="1.0" encoding="gb2312"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
    xmlns:v="urn:schemas-microsoft-com:vml"> 
    <xsl:template match="/">
    <HTML>
    <HEAD>
    <STYLE>v\:*{behavior:url(#default#VML);}</STYLE>
    <TITLE>图表</TITLE>
    </HEAD>
    <BODY>
    <xsl:apply-templates select="votes" />
    </BODY>
    </HTML>
    </xsl:template>
    <xsl:template match="votes">
    <xsl:for-each select="vote">
    <xsl:for-each select="col">
    <v:oval style="POSITION:relative ;Z-INDEX:3;LEFT:100px;TOP:250px;width:50;height:50;" fillcolor="{@color}"
    stroked="f" />
    <v:textbox style="POSITION:relative ;Z-INDEX:3;LEFT:100px;TOP:250px;width:50;height:50;" >
    <xsl:value-of select="@color" />
    <xsl:value-of select="@desc" />
    <xsl:value-of select="." />
    </v:textbox>
    </xsl:for-each>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
      

  2.   

    这样才是真正的图表<?xml version="1.0" encoding="gb2312"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:v="urn:schemas-microsoft-com:vml"> 
    <xsl:template match="/">
    <HTML>
    <HEAD>
    <STYLE>v\:*{behavior:url(#default#VML);}</STYLE>
    <TITLE>图表</TITLE>
    </HEAD>
    <BODY>
    <xsl:apply-templates select="votes" />
    </BODY>
    </HTML>
    </xsl:template>
    <xsl:template match="votes">
    <xsl:for-each select="vote">
    <xsl:for-each select="col">
    <v:rect style="POSITION:relative ;Z-INDEX:3;LEFT:100px;TOP:250px;width:50;height:{.};" fillcolor="{@color}"
    stroked="f" />
    &#160;&#160;
    </xsl:for-each>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>