RSS
热门关键字:  数据挖掘  数据仓库  人工智能  搜索引擎  数据挖掘导论
当前位置 :| 首页>编程技术>xml技术>

xsl 转换 xml 的问题,向大家请教

来源: 作者: 时间:2008-02-13 点击:

《report.xml文件》
<?xml   version="1.0"   encoding="GB2312"?>
<?xml-stylesheet   type="text/xsl"   href="report.xsl"?>
<document>
   
    <report>
        <class>
甲班
        </class>
        <q1> 50 </q1>
        <q2> 70 </q2>
        <q3> 30 </q3>
        <q4> 10 </q4>
    </report>
   
    <report>
        <class>
乙班
        </class>
        <q1> 20 </q1>
        <q2> 30 </q2>
        <q3> 40 </q3> 数据挖掘研究院
        <q4> 50 </q4>
    </report>
   
    <report>
        <class>
  丙班
        </class>
        <q1> 70 </q1>
        <q2> 40 </q2>
        <q3> 20 </q3>
        <q4> 10 </q4>
    </report>
   
</document>

《xsl转换文件》
<?xml   version="1.0"   encoding="gb2312"?>
<xsl:stylesheet   version="1.0"   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template   match="/">
        <html>
            <head> 数据挖掘实验室
                <title> 1999年生产统计 </title>
            </head>
            <body>
                <xsl:apply-templates   select="document"/>
            </body>
        </html>
    </xsl:template>
    <xsl:template   match="document">
        <h3> 1999年生产统计 </h3>
        <table   border="1"   cellspacing="0">
            <th> 班组 </th>
            <th> </th>
            <th> </th>

数据挖掘研究院


            <th> </th>
            <th> </th>
            <xsl:apply-templates   select="report"/>
        </table>
    </xsl:template>
    <xsl:template   match="report">
        <tr>
            <td>
                <xsl:value-of   select="class"/>
            </td>
            <td>
                <xsl:apply-templates   select="q1"/>
            </td>
            <td> 数据挖掘研究院
                <xsl:apply-templates   select="q2"/>
            </td>
            <td>
                <xsl:apply-templates   select="q3"/>
            </td>
            <td>
                <xsl:apply-templates   select="q4"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template   match="q1 ¦q2 ¦q3 ¦q4">
        <!--此处测试产量,如小于等于20则添加一STYLE属性color,其值为red(红色)--> 数据挖掘研究院
        <xsl:if   test="[value()   $le$   20]">
            <xsl:attribute   name="style"> color:red </xsl:attribute>
        </xsl:if>
    </xsl:template>
   
    <xsl:template   match="report">
        <TR>
            <TD>
            </TD>
            <TD>
                <xsl:eval>
                    total(this,"q1")
                </xsl:eval>
            </TD> 数据挖掘实验室
            <TD>
                <xsl:eval>
                    total(this,"q2")
                </xsl:eval>
            </TD>
            <TD>
                <xsl:eval>
                    total(this,"q3")
                </xsl:eval>
            </TD   >
            <TD>
                <xsl:eval>
                    total(this,"q4")
                </xsl:eval>
            </TD>
        </TR>
    </xsl:template>
    <xsl:javascript>
       
        function   total(node,q)
        {
            temp   =   0;
            mark   =   '/document/report/'   +   q;
            v   =   node.selectNodes(mark);
           
            for(   t   =   v.nextNode();   t   ;   t   =   v.nextNode())
            {
                    temp   +=   Number(t.text);
            }
           
            return   temp;
        }
    </xsl:javascript>
</xsl:stylesheet>

运行看不到结果,向各位高手请教!

你的目的是?

想   通过,xsl   格式化输出,rss文件,并且给其中的每条信息,写入javascript脚本参数,然后在程序中打开,这样我就能知道我到底是选择与读了那条新闻,qq:383585946

这个例子是学习,试验这种方法,的可行性

Create By Any-Extract(WL-AE) 数据挖掘研究院

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
匿名?