Is there a technique to combine a pipeline of XSL transformations into a single transformation?

后端 未结 2 677
感情败类
感情败类 2021-01-18 17:28

I have written an application which uses a pipeline of 15 XSL stylesheets, and I\'m beginning to work on tuning its performance. It\'s designed to be portable, so that it ca

2条回答
  •  星月不相逢
    2021-01-18 18:02

    There is a technique that allows independent transformations to be chained together where the output of the k-th transformation is the input of the (k+1)-th transformation.

    Here is a simple example:

    
        
    
     
         
           
         
     
    
     
      
       
      
    
      
     
    
     
         
           
           
         
         
     
    
     
         
           
         
     
    
     
         
          
     
    
    

    when this transformation is applied on the following XML document:

    
    

    the wanted result (the first pass affffds the element as a child of the top element, then the second pass adds another child, , immediately after the element` that was created in the first pass) is produced:

    
       
       
    
    

    There is a very suitable template/function in FXSL to do this: this is the compose-flist template. It takes as parameters an initial data argument and N functions (templates) and produces the chained composition of these functions/templates.

    Here is the test example from the FXSL library:

    
      
      
    
      
    
      
      
      
    
    
      
    
        
        
        Compose:
        (*3).(*2) 3 = 
        
          
          
          
        
    
        
          
          
          
        
    
        Multi Compose:
        (*3).(*2).(*3) 2 = 
        
          
          
        
      
    
      
        
    
        
      
    
      
        
    
        
      
    
    

    when this transformation is applied on any xml document (not used), the wanted, correct result is produced:

    Compose:
    (*3).(*2) 3 = 
    18
    
    Multi Compose:
    (*3).(*2).(*3) 2 = 
    36
    

    Do note: In XSLT 2.0 and later no xxx:node-set() extension is necessary, and any of the chained transformations can be contained in a real function.

提交回复
热议问题