以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  典型xslt分页问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=66473)


--  作者:junxipang
--  发布时间:8/27/2008 4:44:00 PM

--  典型xslt分页问题
各位高人,小妹我初学XML现在在做一个考试系统 数据从数据库中抽出为XML文件
但现在想在客户端表示为html表单,遇到了分页问题.如果仅有一种题型可以分页
但现在有四种题型就不会了.这种结构比较常见,但我baidu,google 了很长时间也没找到解决方案,希望各位给解决一下,在此谢过了 呵呵
以下是数据
<test>
  <danxuan>
    <DanX_Id>6</DanX_Id>
    <DanX_Question>单选1</DanX_Question>
    <DanX_Choice1>g</DanX_Choice1>
    <DanX_Choice2>g</DanX_Choice2>
    <DanX_Choice3>g</DanX_Choice3>
    <DanX_Choice4>gg</DanX_Choice4>
    <DanX_Choice5>g</DanX_Choice5>
    <DanX_Answer>g</DanX_Answer>
    <DanX_Score>55</DanX_Score>
    <DanX_ChoosedMark>false</DanX_ChoosedMark>
  </danxuan>
  <danxuan>
    <DanX_Id>7</DanX_Id>
    <DanX_Question>单选2</DanX_Question>
    <DanX_Choice1>fgfd</DanX_Choice1>
    <DanX_Choice2>gdg</DanX_Choice2>
    <DanX_Choice3>gddg</DanX_Choice3>
    <DanX_Choice4>gdg</DanX_Choice4>
    <DanX_Choice5>gdg</DanX_Choice5>
    <DanX_Answer>dgdfg</DanX_Answer>
    <DanX_Score>22</DanX_Score>
    <DanX_ChoosedMark>false</DanX_ChoosedMark>
  </danxuan>
  <danxuan>
    <DanX_Id>9</DanX_Id>
    <DanX_Question>单选3</DanX_Question>
    <DanX_Choice1>dgdg</DanX_Choice1>
    <DanX_Choice2>fff</DanX_Choice2>
    <DanX_Choice3>fff</DanX_Choice3>
    <DanX_Choice4>fff</DanX_Choice4>
    <DanX_Choice5>fff</DanX_Choice5>
    <DanX_Answer>ff</DanX_Answer>
    <DanX_Score>99</DanX_Score>
    <DanX_ChoosedMark>false</DanX_ChoosedMark>
  </danxuan>
  <danxuan>
    <DanX_Id>14</DanX_Id>
    <DanX_Question>单选4</DanX_Question>
    <DanX_Choice1>df</DanX_Choice1>
    <DanX_Choice2>dff</DanX_Choice2>
    <DanX_Choice3>df</DanX_Choice3>
    <DanX_Choice4>fdf</DanX_Choice4>
    <DanX_Choice5>fdf</DanX_Choice5>
    <DanX_Answer>77</DanX_Answer>
    <DanX_Score>99</DanX_Score>
    <DanX_ChoosedMark>false</DanX_ChoosedMark>
  </danxuan>
  <danxuan>
    <DanX_Id>15</DanX_Id>
    <DanX_Question>单选5</DanX_Question>
    <DanX_Choice1>f</DanX_Choice1>
    <DanX_Choice2>ff</DanX_Choice2>
    <DanX_Choice3>ff</DanX_Choice3>
    <DanX_Choice4>f</DanX_Choice4>
    <DanX_Choice5>f</DanX_Choice5>
    <DanX_Answer>g09</DanX_Answer>
    <DanX_Score>9</DanX_Score>
    <DanX_ChoosedMark>false</DanX_ChoosedMark>
  </danxuan>
  <danxuan>
    <DanX_Id>17</DanX_Id>
    <DanX_Question>单选6</DanX_Question>
    <DanX_Choice1>f</DanX_Choice1>
    <DanX_Choice2>ff</DanX_Choice2>
    <DanX_Choice3>f</DanX_Choice3>
    <DanX_Choice4>f</DanX_Choice4>
    <DanX_Choice5>f</DanX_Choice5>
    <DanX_Answer>f</DanX_Answer>
    <DanX_Score>6</DanX_Score>
    <DanX_ChoosedMark>false</DanX_ChoosedMark>
  </danxuan>
  <danxuan>
    <DanX_Id>18</DanX_Id>
    <DanX_Question>单选7</DanX_Question>
    <DanX_Choice1>s</DanX_Choice1>
    <DanX_Choice2>s</DanX_Choice2>
    <DanX_Choice3>ss</DanX_Choice3>
    <DanX_Choice4>s</DanX_Choice4>
    <DanX_Choice5>s</DanX_Choice5>
    <DanX_Answer>s</DanX_Answer>
    <DanX_Score>55</DanX_Score>
  </danxuan>
  <danxuan>
    <DanX_Id>19</DanX_Id>
    <DanX_Question>单选8</DanX_Question>
    <DanX_Choice1>d</DanX_Choice1>
    <DanX_Choice2>d</DanX_Choice2>
    <DanX_Choice3>d</DanX_Choice3>
    <DanX_Choice4>d</DanX_Choice4>
    <DanX_Choice5>dd</DanX_Choice5>
    <DanX_Answer>d8</DanX_Answer>
    <DanX_Score>8</DanX_Score>
  </danxuan>
  <danxuan>
    <DanX_Id>20</DanX_Id>
    <DanX_Question>单选9</DanX_Question>
    <DanX_Choice1>dfd</DanX_Choice1>
    <DanX_Choice2>dfd</DanX_Choice2>
    <DanX_Choice3>dfdf</DanX_Choice3>
    <DanX_Choice4 />
    <DanX_Choice5 />
    <DanX_Answer />
    <DanX_Score>0</DanX_Score>
  </danxuan>
  <danxuan>
    <DanX_Id>21</DanX_Id>   
      <DanX_Question>单选10</DanX_Question>
    <DanX_Choice1>dfd</DanX_Choice1>
    <DanX_Choice2>dfd</DanX_Choice2>
    <DanX_Choice3>dfdf</DanX_Choice3>
    <DanX_Choice4 />
    <DanX_Choice4 />
    <DanX_Choice5 />
    <DanX_Answer />
    <DanX_Score>0</DanX_Score>
  </danxuan>
  <duoxuan>
    <DuoX_Id>1</DuoX_Id>
    <DuoX_Question>多选1</DuoX_Question>
    <DuoX_Choice1>ll</DuoX_Choice1>
    <DuoX_Choice2>ll</DuoX_Choice2>
    <DuoX_Choice3>l</DuoX_Choice3>
    <DuoX_Choice4>l</DuoX_Choice4>
    <DuoX_Answer>ee</DuoX_Answer>
    <DuoX_Score>33</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>4</DuoX_Id>
    <DuoX_Question>多选2</DuoX_Question>
    <DuoX_Choice1>dd</DuoX_Choice1>
    <DuoX_Choice2>dd</DuoX_Choice2>
    <DuoX_Choice3>dd</DuoX_Choice3>
    <DuoX_Choice4>dd</DuoX_Choice4>
    <DuoX_Choice5>dd</DuoX_Choice5>
    <DuoX_Answer>dddd</DuoX_Answer>
    <DuoX_Score>66</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>5</DuoX_Id>
    <DuoX_Question>多选3</DuoX_Question>
    <DuoX_Choice1>dfs</DuoX_Choice1>
    <DuoX_Choice2>fdsfs</DuoX_Choice2>
    <DuoX_Choice3>fsdfsdfsf</DuoX_Choice3>
    <DuoX_Choice4>fs</DuoX_Choice4>
    <DuoX_Choice5>f</DuoX_Choice5>
    <DuoX_Answer>99</DuoX_Answer>
    <DuoX_Score>99</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>6</DuoX_Id>
    <DuoX_Question>多选4</DuoX_Question>
    <DuoX_Choice1>yy</DuoX_Choice1>
    <DuoX_Choice2>yyy</DuoX_Choice2>
    <DuoX_Choice3>yy</DuoX_Choice3>
    <DuoX_Choice4>yy</DuoX_Choice4>
    <DuoX_Choice5>yy</DuoX_Choice5>
    <DuoX_Answer>77</DuoX_Answer>
    <DuoX_Score>77</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>7</DuoX_Id>
    <DuoX_Question>多选5</DuoX_Question>
    <DuoX_Choice1>gg</DuoX_Choice1>
    <DuoX_Choice2>ggg</DuoX_Choice2>
    <DuoX_Choice3>gg</DuoX_Choice3>
    <DuoX_Choice4>gg</DuoX_Choice4>
    <DuoX_Choice5>gg</DuoX_Choice5>
    <DuoX_Answer>gg</DuoX_Answer>
    <DuoX_Score>55</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>8</DuoX_Id>
    <DuoX_Question>多选6</DuoX_Question>
    <DuoX_Choice1>ff</DuoX_Choice1>
    <DuoX_Choice2>ff</DuoX_Choice2>
    <DuoX_Choice3>ff</DuoX_Choice3>
    <DuoX_Choice4>f</DuoX_Choice4>
    <DuoX_Choice5>f</DuoX_Choice5>
    <DuoX_Answer>r</DuoX_Answer>
    <DuoX_Score>33</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>9</DuoX_Id>
    <DuoX_Question>多选7</DuoX_Question>
    <DuoX_Choice1>df</DuoX_Choice1>
    <DuoX_Choice2>df</DuoX_Choice2>
    <DuoX_Choice3>fdf</DuoX_Choice3>
    <DuoX_Choice4>fdf</DuoX_Choice4>
    <DuoX_Choice5>dfdf</DuoX_Choice5>
    <DuoX_Answer>fdf</DuoX_Answer>
    <DuoX_Score>77</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>10</DuoX_Id>
    <DuoX_Question>多选8</DuoX_Question>
    <DuoX_Choice1>df</DuoX_Choice1>
    <DuoX_Choice2>dfdf</DuoX_Choice2>
    <DuoX_Choice3>fsfsf</DuoX_Choice3>
    <DuoX_Choice4>fsfsf</DuoX_Choice4>
    <DuoX_Choice5>fsfs</DuoX_Choice5>
    <DuoX_Answer>88</DuoX_Answer>
    <DuoX_Score>99</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>11</DuoX_Id>
    <DuoX_Question>多选9</DuoX_Question>
    <DuoX_Choice1 />
    <DuoX_Choice2 />
    <DuoX_Choice3 />
    <DuoX_Choice4 />
    <DuoX_Choice5 />
    <DuoX_Answer />
    <DuoX_Score>0</DuoX_Score>
  </duoxuan>
  <duoxuan>
    <DuoX_Id>12</DuoX_Id>
    <DuoX_Question>多选10</DuoX_Question>
    <DuoX_Choice1>null</DuoX_Choice1>
    <DuoX_Choice2 />
    <DuoX_Choice3 />
    <DuoX_Choice4 />
    <DuoX_Choice5 />
    <DuoX_Answer />
    <DuoX_Score>0</DuoX_Score>
  </duoxuan>
  <panduan>
    <PD_Id>1</PD_Id>
    <PD_Question>判断1</PD_Question>
    <PD_Answer>false</PD_Answer>
    <PD_Score>1121</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>2</PD_Id>
    <PD_Question>判断2</PD_Question>
    <PD_Answer>true</PD_Answer>
    <PD_Score>1451</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>3</PD_Id>
    <PD_Question>判断3</PD_Question>
    <PD_Answer>true</PD_Answer>
    <PD_Score>12</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>4</PD_Id>
    <PD_Question>判断4</PD_Question>
    <PD_Answer>false</PD_Answer>
    <PD_Score>454</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>5</PD_Id>
    <PD_Question>判断5</PD_Question>
    <PD_Answer>false</PD_Answer>
    <PD_Score>32</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>6</PD_Id>
    <PD_Question>判断6</PD_Question>
    <PD_Answer>false</PD_Answer>
    <PD_Score>96</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>7</PD_Id>
    <PD_Question>判断7</PD_Question>
    <PD_Answer>true</PD_Answer>
    <PD_Score>100</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>8</PD_Id>
    <PD_Question>判断8</PD_Question>
    <PD_Answer>false</PD_Answer>
    <PD_Score>22</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>9</PD_Id>
    <PD_Question>判断9</PD_Question>
    <PD_Answer>true</PD_Answer>
    <PD_Score>33</PD_Score>
  </panduan>
  <panduan>
    <PD_Id>10</PD_Id>
    <PD_Question>判断10</PD_Question>
    <PD_Answer>false</PD_Answer>
    <PD_Score>21</PD_Score>
  </panduan>
  <tiankong>
    <TK_Id>1</TK_Id>
    <TK_Question>填空1</TK_Question>
    <TK_Answer>ttttuuuu</TK_Answer>
    <TK_Score>99</TK_Score>
  </tiankong>
  <tiankong>
    <TK_Id>4</TK_Id>
    <TK_Question>填空2</TK_Question>
    <TK_Answer>dfdf</TK_Answer>
    <TK_Score>22</TK_Score>
  </tiankong>
  <tiankong>
    <TK_Id>5</TK_Id>
    <TK_Question>填空3</TK_Question>
    <TK_Answer>dffdd</TK_Answer>
    <TK_Score>2345</TK_Score>
  </tiankong>
  <tiankong>
    <TK_Id>6</TK_Id>
    <TK_Question>填空4</TK_Question>
    <TK_Answer>dgd</TK_Answer>
    <TK_Score>67</TK_Score>
  </tiankong>
  <tiankong>
    <TK_Id>7</TK_Id>
    <TK_Question>填空5</TK_Question>
    <TK_Answer />
    <TK_Score>0</TK_Score>
  </tiankong>
</test>

--  作者:junxipang
--  发布时间:8/28/2008 8:20:00 AM

--  
麻烦斑竹抽时间帮忙解决一下 再次感谢了!!!!!!!!
--  作者:Qr
--  发布时间:8/28/2008 11:09:00 AM

--  
http://blogger.org.cn/blog/more.asp?name=Qr&id=10629
--  作者:junxipang
--  发布时间:8/28/2008 2:11:00 PM

--  
谢谢斑竹回复 但我还是不理解 您能否按着我的数据给我分一下页
这样我也容易理解一下 谢谢啦
--  作者:Qr
--  发布时间:8/29/2008 9:07:00 AM

--  
其实没什么难的,关键语句就以下这一行
<xsl:apply-templates select="//danxuan[position()>=1 and position() &lt;= 20]"/>
意思是遍历第1到第20个danxuan用于输出,你只需要将这两个数值用变量来表示,然后通过脚本,或模板递归,或其它方法去修改这两个数值,如输出21-40,就是[position()>=21 and position() &lt;= 40]
只是你的XML根节点下的子节点不相同,就不能直接“//danxuan”,而是“test/*”。
--  作者:junxipang
--  发布时间:8/29/2008 2:03:00 PM

--  
谢谢斑竹 我在研究一下 呵呵 如果不懂还要向您请教呀!!!!!! 对于我们这些
初学者每一步都是坎,希望有高手帮帮忙呵呵 谢谢啦
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
125.000ms