pagination in xsl

前端 未结 1 1600
北荒
北荒 2021-01-15 17:02

I have an xml file and also an xsl file which I wrote for it to generate html. my xml file is:




        
1条回答
  •  醉话见心
    2021-01-15 17:53

    I. Here is a small example showing how to implement "paging"

    Given this source XML document:

    
      01
      02
      03
      04
      05
      06
      07
      08
      09
      10
    
    

    and given a pagesize of 3, this XSLT 1.0 transformation:

    
     
     
    
     
         
           
         
     
    
     
      
        
      
     
    
     
    
     
      
     
    
    

    produces:

    
       
          01
          02
          03
       
       
          04
          05
          06
       
       
          07
          08
          09
       
       
          10
       
    
    

    Do note:

    It isn't possible by only using pure XSLT 1.0 to produce more than one result document by a single transformation.

    You can either use XSLT 2.0 and its xsl:result-document instruction, or an XSLT 1.0 processor that implements EXSLT's extension element. Another alternative is to initiate a separate XSLT 1.0 transformation for every output page.


    II. Paging with XSLT 2.0

    
     
     
    
     
    
     
      
         
          
            
          
         
        
     
    
     
      

    When this transformation is applied on the same XML document (above). it successfully creates four result documents.

    And Saxon 8.7.01 issues this:

    Saxon 9.1.0.7J from Saxonica
    
    Java version 1.6.0_17
    
    Stylesheet compilation time: 223 milliseconds
    
    Processing file:/C:\CVS-DDN\fxsl-xslt2\data\numList.xml
    
    Building tree for file:/C:\CVS-DDN\fxsl-xslt2\data\numList.xml using class net.sf.saxon.tinytree.TinyBuilder
    
    Tree built in 2 milliseconds
    
    Tree size: 23 nodes, 20 characters, 0 attributes
    
    Loading net.sf.saxon.event.MessageEmitter
    
    Writing to file:/c:/temp/delete/page1
    
    Writing to file:/c:/temp/delete/page2
    
    Writing to file:/c:/temp/delete/page3
    
    Writing to file:/c:/temp/delete/page4
    
    Execution time: 73 milliseconds
    
    Memory used: 21482856
    
    NamePool contents: 21 entries in 20 chains. 6 prefixes, 7 URIs
    

    0 讨论(0)
提交回复
热议问题