有2个文件:Page.xml和Page.xsl

Page.xml:


XML之动态排序_stylesheet

<?

xml version="1.0" encoding="gb2312"  ?>

XML之动态排序_stylesheet

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

XML之动态排序_stylesheet

< BlueIdea >

XML之动态排序_stylesheet

    

< team >

XML之动态排序_stylesheet

        

< blue_ID > 1 </ blue_ID >

XML之动态排序_stylesheet

        

< blue_name > 车仔 </ blue_name >

XML之动态排序_stylesheet

        

< blue_text > 一个简单的排序 </ blue_text >

XML之动态排序_stylesheet

        

< blue_time > 2002-1-11 17:35:33 </ blue_time >

XML之动态排序_stylesheet

        

< blue_class > XML专题 </ blue_class >

XML之动态排序_stylesheet

    

</ team >

XML之动态排序_stylesheet

     

< team >

XML之动态排序_stylesheet

        

< blue_ID > 2 </ blue_ID >

XML之动态排序_stylesheet

        

< blue_name > flyingbird </ blue_name >

XML之动态排序_stylesheet

        

< blue_text > 嫁给你,是要你疼的 </ blue_text >

XML之动态排序_stylesheet

        

< blue_time > 2001-09-06 12:45:51 </ blue_time >

XML之动态排序_stylesheet

        

< blue_class > 灌水精华 </ blue_class >

XML之动态排序_stylesheet

    

</ team >

XML之动态排序_stylesheet

     

< team >

XML之动态排序_stylesheet

        

< blue_ID > 3 </ blue_ID >

XML之动态排序_stylesheet

        

< blue_name > 苛子 </ blue_name >

XML之动态排序_stylesheet

        

< blue_text > 正则表达式在UBB论坛中的应用 </ blue_text >

XML之动态排序_stylesheet

        

< blue_time > 2001-11-23 21:02:16 </ blue_time >

XML之动态排序_stylesheet

        

< blue_class > Web 编程精华 </ blue_class >

XML之动态排序_stylesheet

    

</ team >

XML之动态排序_stylesheet

     

< team >

XML之动态排序_stylesheet

        

< blue_ID > 4 </ blue_ID >

XML之动态排序_stylesheet

        

< blue_name > 太乙郎 </ blue_name >

XML之动态排序_stylesheet

        

< blue_text > 年末经典分舵聚会完全手册 v0.1 </ blue_text >

XML之动态排序_stylesheet

        

< blue_time > 2000-12-08 10:22:48 </ blue_time >

XML之动态排序_stylesheet

        

< blue_class > 论坛灌水区 </ blue_class >

XML之动态排序_stylesheet

    

</ team >

XML之动态排序_stylesheet

     

< team >

XML之动态排序_stylesheet

        

< blue_ID > 5 </ blue_ID >

XML之动态排序_stylesheet

        

< blue_name > mmkk </ blue_name >

XML之动态排序_stylesheet

        

< blue_text > Asp错误信息总汇 </ blue_text >

XML之动态排序_stylesheet

        

< blue_time > 2001-10-13 16:39:05 </ blue_time >

XML之动态排序_stylesheet

        

< blue_class > javascript脚本 </ blue_class >

XML之动态排序_stylesheet

    

</ team >

XML之动态排序_stylesheet

</ BlueIdea >


Page.xsl:


XML之动态排序_stylesheet

<? xml version="1.0" encoding="gb2312" 

?>

XML之动态排序_stylesheet

< xsl:stylesheet  xmlns:xsl ="http://www.w3.org/TR/WD-xsl" >

XML之动态排序_stylesheet

     <

xsl:template  match ="/" >

XML之动态排序_stylesheet

         <

html >

XML之动态排序_stylesheet

         <

head >

XML之动态排序_stylesheet

         <

title >

XML之动态排序_stylesheet

        车仔手札--XML卷之(3):动态分页

XML之动态排序_stylesheet

         </

title >

XML之动态排序_stylesheet

         <

style >

XML之动态排序_stylesheet

            body,BlueIdea,team,blue_ID,blue_name,blue_text,blue_time,blue_class{ font: 12px "宋体", "Arial", "Times New Roman"; } 

XML之动态排序_stylesheet

            table { font-size: 12px;  border: 0px double; border-color: #99CC99 #99CC99 #CCCCCC #CCCCCC; cellpadding:3;cellspacing:3; bgcolor:#eeeeee; text-decoration: blink} 

XML之动态排序_stylesheet

            .keybutton {  cursor:hand;  font-size: 12px; color: #003300;  background: #ffffff; border: 0px solid;}

XML之动态排序_stylesheet

         </

style >  

XML之动态排序_stylesheet

                 <

script >

XML之动态排序_stylesheet

                     <

xsl:comment >

XML之动态排序_stylesheet

                         <![CDATA[


XML之动态排序_stylesheet

                            var search;

XML之动态排序_stylesheet

                            var OnePageNum=2;

XML之动态排序_stylesheet

                            var PageNum=1;

XML之动态排序_stylesheet

                            var XMLPageNum=1;

XML之动态排序_stylesheet

                            function window.onload()

XML之动态排序_stylesheet

                            {

XML之动态排序_stylesheet

                                stylesheet=document.XSLDocument;

XML之动态排序_stylesheet

                                source=document.XMLDocument;

XML之动态排序_stylesheet

                                nodes=source.documentElement.childNodes;

XML之动态排序_stylesheet

                                len=nodes.length;

XML之动态排序_stylesheet

                                for(i=1;i<=(len/OnePageNum);i++);

XML之动态排序_stylesheet

                                XMLPageNum=i;    

XML之动态排序_stylesheet

                            }

XML之动态排序_stylesheet

                            

XML之动态排序_stylesheet

                            function pages(Num)

XML之动态排序_stylesheet

                            {

XML之动态排序_stylesheet

                                var firstNum=0;

XML之动态排序_stylesheet

                                var lastNume=0;            

XML之动态排序_stylesheet

                                if (Num=="first") {PageNum=1;}

XML之动态排序_stylesheet

                                if (Num=="previous") {if (PageNum>1) PageNum -=1;}

XML之动态排序_stylesheet

                                if (Num=="next") {if (PageNum<XMLPageNum) PageNum +=1;}

XML之动态排序_stylesheet

                                if (Num=="last") {PageNum =XMLPageNum;}

XML之动态排序_stylesheet

                                sortField=document.XSLDocument.selectSingleNode("//@expr");

XML之动态排序_stylesheet

                                firstNum=OnePageNum*(PageNum-1)+1;

XML之动态排序_stylesheet

                                lastNum=OnePageNum*(PageNum-1)+OnePageNum;

XML之动态排序_stylesheet

                                text="childnumber(this)>="+firstNum+" & childnumber(this)<="+lastNum;

XML之动态排序_stylesheet

                                sortField.value=text;

XML之动态排序_stylesheet

                                Layer1.innerHTML=source.documentElement.transformNode(stylesheet);

XML之动态排序_stylesheet

                            }    

XML之动态排序_stylesheet

                         ]]>


XML之动态排序_stylesheet

                     </

xsl:comment >     

XML之动态排序_stylesheet

                 </

script >

XML之动态排序_stylesheet

         </

head >

XML之动态排序_stylesheet

         <

body >

XML之动态排序_stylesheet

             <

table  align ="center"  width ="600"   >

XML之动态排序_stylesheet

                 <

tr >  

XML之动态排序_stylesheet

                     <

td >  

XML之动态排序_stylesheet

                       <

button  id ="cmdfirstPage"   class ="keybutton"    onclick ="pages('first');"   > 首页 </ button >

XML之动态排序_stylesheet

                       <

button  id ="cmdpreviousPage"   class ="keybutton"    onclick ="pages('previous');"   > 上一页 </ button >

XML之动态排序_stylesheet

                       <

button  id ="cmdnextPage"  class ="keybutton"   onclick ="pages('next');" > 下一页 </ button >

XML之动态排序_stylesheet

                       <

button  id ="cmdlastPage"  class ="keybutton"   onclick ="pages('last');" > 尾页 </ button >

XML之动态排序_stylesheet

                     </

td >

XML之动态排序_stylesheet

               </

tr >

XML之动态排序_stylesheet

             </

table >

XML之动态排序_stylesheet

             <

br  />

XML之动态排序_stylesheet

             <

div  id ="Layer1"  name ="Layer1" >   < xsl:apply-templates  select ="BlueIdea"   /></ div >                           

XML之动态排序_stylesheet

         </

body >

XML之动态排序_stylesheet

         </

html >     

XML之动态排序_stylesheet

     </

xsl:template >

XML之动态排序_stylesheet

    

XML之动态排序_stylesheet

     <

xsl:template  match ="BlueIdea" >

XML之动态排序_stylesheet

         <

table  width ="600"  border ="1"  align ="center"  cellpadding ="1"  cellspacing ="1"  bordercolordark ="#ffffff"  bordercolorlight ="#ADAAAD" >

XML之动态排序_stylesheet

             <

tr  bgcolor ="#FFCC99"  align ="center" >

XML之动态排序_stylesheet

                 <

td > 编号 </ td >

XML之动态排序_stylesheet

                 <

td > 姓名 </ td >

XML之动态排序_stylesheet

                 <

td > 主题 </ td >

XML之动态排序_stylesheet

                 <

td > 发表时间 </ td >

XML之动态排序_stylesheet

                 <

td > 归类 </ td >

XML之动态排序_stylesheet

             </

tr >             

XML之动态排序_stylesheet

             <

xsl:apply-templates  select ="team"  order-by ="blue_ID" />

XML之动态排序_stylesheet

         </

table >         

XML之动态排序_stylesheet

     </

xsl:template >

XML之动态排序_stylesheet

            

XML之动态排序_stylesheet

     <

xsl:template  match ="team" >

XML之动态排序_stylesheet

         <

xsl:if  expr ="childnumber(this)&gt;=1 &amp; childnumber(this)&lt;=2 " >

XML之动态排序_stylesheet

         <

tr   align ="center" >

XML之动态排序_stylesheet

             <

xsl:apply-templates  select ="blue_ID"   />

XML之动态排序_stylesheet

             <

xsl:apply-templates  select ="blue_name"   />

XML之动态排序_stylesheet

             <

xsl:apply-templates  select ="blue_text"   />

XML之动态排序_stylesheet

             <

xsl:apply-templates  select ="blue_time"   />

XML之动态排序_stylesheet

             <

xsl:apply-templates  select ="blue_class"   />

XML之动态排序_stylesheet

         </

tr >

XML之动态排序_stylesheet

         </

xsl:if >     

XML之动态排序_stylesheet

     </

xsl:template >     

XML之动态排序_stylesheet

    

XML之动态排序_stylesheet

     <

xsl:template  match ="blue_ID" >

XML之动态排序_stylesheet

         <

td  bgcolor ="#eeeeee" >

XML之动态排序_stylesheet

             <

xsl:value-of  />

XML之动态排序_stylesheet

         </

td >

XML之动态排序_stylesheet

     </

xsl:template >

XML之动态排序_stylesheet

     <

xsl:template  match ="blue_name" >

XML之动态排序_stylesheet

         <

td >< xsl:value-of  /></ td >

XML之动态排序_stylesheet

     </

xsl:template >

XML之动态排序_stylesheet

     <

xsl:template  match ="blue_text" >

XML之动态排序_stylesheet

         <

td >

XML之动态排序_stylesheet

             <

xsl:value-of  />

XML之动态排序_stylesheet

         </

td >

XML之动态排序_stylesheet

     </

xsl:template >

XML之动态排序_stylesheet

     <

xsl:template  match ="blue_time" >

XML之动态排序_stylesheet

         <

td >

XML之动态排序_stylesheet

             <

xsl:value-of  />

XML之动态排序_stylesheet

         </

td >

XML之动态排序_stylesheet

     </

xsl:template >

XML之动态排序_stylesheet

     <

xsl:template  match ="blue_class" >

XML之动态排序_stylesheet

         <

td >             

XML之动态排序_stylesheet

             <

xsl:value-of  />

XML之动态排序_stylesheet

         </

td >

XML之动态排序_stylesheet

     </

xsl:template >

XML之动态排序_stylesheet

    

XML之动态排序_stylesheet

</ xsl:stylesheet >