| 发表于:2007-09-09 10:55:27 楼主 |
把xml文件读取到网页中,然后通过表单提交再存储到另一个xml文件中; 读取xml这一步我直接定义了xsl,可是这样一来网页中的后缀就是.xml了,好像不合乎常理吧;如果这样可以,那么表单提交之后处理的jsp是不是不能按照普通的jsp来写呢? 代码贴出来看看吧 xml文件: <?xml version= "1.0 " encoding= "gb2312 "?> <?xml-stylesheet type= "text/xsl " href= "choice_template.xsl "?> <document> <questions> <course_name> 信息系统开发
 </course_name> <knowledge_point> 数据与信息
 </knowledge_point> <unit_num> 第1讲
 </unit_num> <difficulty> 0.5
 </difficulty> <separating_capacity> 0.6
 </separating_capacity> <point> 1
 </point> <question> ()是关于客观事实的可进行通信的知识。
 </question> <answer_a> a. 信息
 </answer_a> <answer_b> b. 数据
 </answer_b> <answer_c> c.管理信息
 </answer_c> <answer_d> d.管理信息系统
 </answer_d> <answer> a
 </answer> </questions> </document> 下面是我定义的xsl文件: <?xml version= "1.0 " encoding= "gb2312 "?> <xsl:stylesheet xmlns:xsl= "http://www.w3.org/tr/wd-xsl "> <!--根模板--> <xsl:template match= "/ "> <html> <head> <title> 单项选择题 </title> </head> <body> <xsl:apply-templates select= "document/questions "/> </body> </html> </xsl:template> <!--单选模板--> <xsl:template match= "questions "> <form action= "submit.jsp "> <table border= "0 " cellspacing= "0 "> <xsl:apply-templates select= "question "/> <xsl:apply-templates select= "answer_a "/> <xsl:apply-templates select= "answer_b "/> <xsl:apply-templates select= "answer_c "/> <xsl:apply-templates select= "answer_d "/> <xsl:apply-templates select= "answer "/> <br/> <tr/> <td colspan= "2 " align= "center "> <input type= "submit " name= "submit " value= "提交 " /> </td> </table> </form> </xsl:template> <!--试题内容模板--> <xsl:template match= "question "> <tr> <td> <xsl:eval> formatindex(childnumber(this), "1 ") </xsl:eval> </td> <td> 、 <xsl:value-of/> </td> </tr> <tr> <td style= "visibility:hidden "> test </td> </tr> </xsl:template> <!--选项模板--> <xsl:template match= "answer_a "> <tr> <td> <input type= "radio " name= "checkbox " value= "checkbox " /> </td> <td align= "left "> <xsl:value-of/> </td> </tr> </xsl:template> <xsl:template match= "answer_b "> <tr> <td> <input type= "radio " name= "checkbox " value= "checkbox " /> </td> <td> <xsl:value-of/> </td> </tr> </xsl:template> <xsl:template match= "answer_c "> <tr> <td> <input type= "radio " name= "checkbox " value= "checkbox " /> </td> <td> <xsl:value-of/> </td> </tr> </xsl:template> <xsl:template match= "answer_d "> <tr> <td> <input type= "radio " name= "checkbox " value= "checkbox " /> </td> <td> <xsl:value-of/> </td> </tr> </xsl:template> <!--答案模板--> <xsl:template match= "answer "> <tr> <td style= "visibility:hidden " colspan= "2 "> <xsl:value-of/> </td> </tr> </xsl:template> </xsl:stylesheet> 那接下来的submit.jsp该怎样写呢? |
|
|
|
|