-- 作者:宇宙人
-- 发布时间:6/26/2004 1:19:00 AM
--
在xslt中我这么写的! 原xml文件: <?xml version="1.0" encoding="utf-8"?> <!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by zqm (ihep) --> <?xml-stylesheet type="text/xsl" href= "mystyle.xsl"?> <Survey> <head> <discription bold="true" italic="true" underline="true" color="rgb(255,0,255)" fontsize="30">某产品调查问卷 </discription> </head> <singal_choice id="1"> <title bold="true" italic="false" underline="flase" color="rgb(0,0,255)" fontsize="20">你是否使用过本产品? </title> <choice bold="flase" italic="flase" underline="flase" color="rgb(0,0,0)" fontsize="20"> 是 </choice> <choice bold="flase" italic="flase" underline="flase" color="rgb(0,0,0)" fontsize="20"> 否 </choice> </singal_choice> <multy_choice id="2"> <title bold="true" italic="flase" underline="flase" color="rgb(0,0,255)" fontsize="20">你认为本产品有那些缺点? </title> <choice bold="flase" italic="flase" underline="flase" color="rgb(0,0,0)" fontsize="20"> 价格高 </choice> <choice bold="flase" italic="flase" underline="flase" color="rgb(0,0,0)" fontsize="20"> 性能差 </choice> <choice bold="flase" italic="flase" underline="flase" color="rgb(0,0,0)" fontsize="20"> 质量差 </choice> </multy_choice> <short_answer id="3"> <title bold="true" italic="flase" underline="flase" color="rgb(0,0,255)" fontsize="20">你不使用本产品的原因是? </title> </short_answer> </Survey> 对应的xslt文件: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title>问卷调查</title> </head> <body> <xsl:for-each select="Survey"> <!--调查问卷的题目--> <xsl:for-each select="head"> <div align="center"> <span> <xsl:attribute name="style"><xsl:if test="discription[@italic='true']"> font-style:italic; </xsl:if><xsl:if test="discription[@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="discription/@fontsize"/>pt; color:<xsl:value-of select="discription/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="discription[@underline='true']"> <u> <xsl:value-of select="discription"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="discription"/> </xsl:otherwise> </xsl:choose> </span> </div> </xsl:for-each> <hr/> <form action="post.asp" method="post"> <table align="center" border="0" width="60%"> <!--单选问题]--> <xsl:for-each select="singal_choice"> <!--问题题目]--> <tr> <span> <xsl:attribute name="style"><xsl:if test="title[@italic='true']"> font-style:italic; </xsl:if><xsl:if test="title[@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="title/@fontsize"/>pt; color:<xsl:value-of select="title/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="title[@underline='true']"> <u> <xsl:value-of select="@id"/>.<xsl:value-of select="title"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="@id"/>.<xsl:value-of select="title"/> </xsl:otherwise> </xsl:choose> </span> </tr> <!--问题选项]--> <!--选项一]--> <tr> <input type="radio" name="singal" value="yes"/> <span> <xsl:attribute name="style"><xsl:if test="choice[1][@italic='true']"> font-style:italic; </xsl:if><xsl:if test="choice[1][@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="choice[1]/@fontsize"/>pt; color:<xsl:value-of select="choice[1]/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="choice[1][@underline='true']"> <u> <xsl:value-of select="choice[1]"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="choice[1]"/> </xsl:otherwise> </xsl:choose> </span> </tr> <!--选项二]--> <tr> <input type="radio" name="singal" value="no"/> <span> <xsl:attribute name="style"><xsl:if test="choice[2][@italic='true']"> font-style:italic; </xsl:if><xsl:if test="choice[2][@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="choice[2]/@fontsize"/>pt; color:<xsl:value-of select="choice[2]/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="choice[2][@underline='true']"> <u> <xsl:value-of select="choice[2]"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="choice[2]"/> </xsl:otherwise> </xsl:choose> </span> </tr> </xsl:for-each> <!--多选问题--> <xsl:for-each select="multy_choice"> <!--问题题目]--> <tr> <span> <xsl:attribute name="style"><xsl:if test="title[@italic='true']"> font-style:italic; </xsl:if><xsl:if test="title[@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="title/@fontsize"/>pt; color:<xsl:value-of select="title/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="title[@underline='true']"> <u> <xsl:value-of select="@id"/>.<xsl:value-of select="title"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="@id"/>.<xsl:value-of select="title"/> </xsl:otherwise> </xsl:choose> </span> </tr> <!--问题选项]--> <!--选项一]--> <tr> <input type="checkbox" name="multi_1" value="1"/> <span> <xsl:attribute name="style"><xsl:if test="choice[1][@italic='true']"> font-style:italic; </xsl:if><xsl:if test="choice[1][@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="choice[1]/@fontsize"/>pt; color:<xsl:value-of select="choice[1]/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="choice[1][@underline='true']"> <u> <xsl:value-of select="choice[1]"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="choice[1]"/> </xsl:otherwise> </xsl:choose> </span> </tr> <!--选项二]--> <tr> <input type="checkbox" name="multi_2" value="1"/> <span> <xsl:attribute name="style"><xsl:if test="choice[2][@italic='true']"> font-style:italic; </xsl:if><xsl:if test="choice[2][@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="choice[2]/@fontsize"/>pt; color:<xsl:value-of select="choice[2]/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="choice[2][@underline='true']"> <u> <xsl:value-of select="choice[2]"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="choice[2]"/> </xsl:otherwise> </xsl:choose> </span> </tr> <!--选项三]--> <tr> <input type="checkbox" name="multi_3" value="1"/> <span> <xsl:attribute name="style"><xsl:if test="choice[3][@italic='true']"> font-style:italic; </xsl:if><xsl:if test="choice[3][@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="choice[3]/@fontsize"/>pt; color:<xsl:value-of select="choice[3]/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="choice[3][@underline='true']"> <u> <xsl:value-of select="choice[3]"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="choice[3]"/> </xsl:otherwise> </xsl:choose> </span> </tr> </xsl:for-each> <!--简答题--> <xsl:for-each select="short_answer"> <!--问题题目]--> <tr> <span> <xsl:attribute name="style"><xsl:if test="title[@italic='true']"> font-style:italic; </xsl:if><xsl:if test="title[@bold='true']"> font-weight:bold; </xsl:if> font-size:<xsl:value-of select="title/@fontsize"/>pt; color:<xsl:value-of select="title/@color"/>; </xsl:attribute> <xsl:choose> <xsl:when test="title[@underline='true']"> <u> <xsl:value-of select="@id"/>.<xsl:value-of select="title"/> </u> </xsl:when> <xsl:otherwise> <xsl:value-of select="@id"/>.<xsl:value-of select="title"/> </xsl:otherwise> </xsl:choose> </span> </tr> <tr> <textarea rows="5" cols="40" name="text"></textarea> </tr> </xsl:for-each> <tr> <td align="center"> <input type="submit" name="submit" value="提交"/> </td> </tr> </table> </form> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
|