以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XML源码及示例(仅原创和转载) 』  (http://bbs.xml.org.cn/list.asp?boardid=32)
----  xml+xslt问题:不能正常显示  (http://bbs.xml.org.cn/dispbbs.asp?boardid=32&rootid=&id=21398)


--  作者:臭p孩儿
--  发布时间:8/23/2005 2:01:00 PM

--  xml+xslt问题:不能正常显示

student.xml

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="mystyle.xsl"?>

<roster>

    The roster of the students

    <student>

        <name>Li Hua</name>

        <origin>He Bei</origin>
        <age>15</age>

        <telephone>325242352</telephone>

    </student>    

    <student>

        <name>Zhang San</name>

        <origin>Bei Jing</origin>

        <age>15</age>

        <telephone>6457464</telephone>

    </student>

</roster>

mystyle.xsl

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns="http://www.w3.org/TR/REC-html40">

<xsl:template>

<xsl:apply-templates />

</xsl:template>

<xsl:template match="/">

    <html>

        <head>

            <title>Memberlist Of Student</title>

            <style>

                .title{font-size:15pt; font-weight:bold; color:blue}

                .name {color:red}

            </style>

        </head>

        <body>

            <p class="title">Memberlist Of Student</p>

            <xsl:apply-templates select="roster"/>

        </body>

    </html>

</xsl:template>

<xsl:template match="roster">

    <table border="1">

        <thead>

            <td><b>name</b></td>

            <td><b>origin</b></td>

            <td><b>age</b></td>

            <td><b>telephone</b></td>

        </thead>

        <xsl:for-each select="student" order-by="name">

        <tr>

            <td><b><xsl:value-of select="name"/></b></td>

            <td><b><xsl:value-of select="origin"/></b></td>

            <td><b><xsl:value-of select="age"/></b></td>

            <td><b><xsl:value-of select="telephone"/></b></td>

        </tr>

        </xsl:for-each>

    </table>

</xsl:template>

</xsl:stylesheet>


--------------------------------------------------------------------------------


可是当我浏览的时候 提示:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Required attribute 'version' is missing.

晕啊,啥原因呢???哥哥们帮忙


--  作者:Qr
--  发布时间:8/23/2005 3:13:00 PM

--  
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/REC-html40">


--  作者:jackeyzsu
--  发布时间:8/23/2005 4:13:00 PM

--  
好像XSL中多了一段:
<xsl:template>

<xsl:apply-templates />

</xsl:template>

还有就是order-by好像已经过时了吧,该用<xsl:sort>


--  作者:jackeyzsu
--  发布时间:8/23/2005 4:25:00 PM

--  
好像XSL中多了一段:
<xsl:template>

<xsl:apply-templates />

</xsl:template>

还有就是order-by好像已经过时了吧,该用<xsl:sort>


--  作者:Qr
--  发布时间:8/23/2005 4:46:00 PM

--  
http://www.w3.org/1999/XSL/Transform只能用<xsl:sort>,没有order-by
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
54.688ms