以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  求助:单选框(Radiobutton)和多选框(Checkbox)的显示!  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=8404)


--  作者:mymygirl
--  发布时间:6/20/2004 7:56:00 PM

--  求助:单选框(Radiobutton)和多选框(Checkbox)的显示!
正在编一个调查表的转换程序,用XSLT将一个调查表的XML文档转换成XSL-FO,然后再生成PDF文件,中间有一些单选和多选的问答,要以表格的方式显示,那么在XSL-FO里是怎么表示
单选框(RadioButton)和多选框(Checkbox)呢?

请各位大虾帮忙!多谢啦!


--  作者:宇宙人
--  发布时间: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>


--  作者:yangjinhui
--  发布时间:6/29/2004 9:53:00 AM

--  
问一下上面的东东,怎么才能让学习XML 能够入门。
我是一个初学者
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
140.625ms