XSLT call-template with dynamic QName?

前端 未结 5 1489
闹比i
闹比i 2020-12-31 20:13

I have searched all around to find a solution to my problem, but i just got more questions...

consider the following XML:


               


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-31 20:49

    From http://www.w3.org/TR/xslt#named-templates

    The value of the name attribute is a QName, which is expanded as described in [2.4 Qualified Names].

    It means that is neither an expression nor an AVT.

    Explicit xsl:call-template instructions are fine whether by logic instructions or pattern matching like:

    
     
    
    

    Another approach is named template references...

    
        
        
            
        
         one 
         two 
         three 
         four 
     
    

    Output:

     one  two  three  four 
    


    Note: Because this technique uses document('') to process the XSLT rather than the original XML file, the original document being processed is not available in the named templates. However, you can explicitly pass current() as parameter to the templates if needed:

        
            
                
            
        
    

    If needed, $current can be used to access the original document:

        
            
            
             becomes one 
        
    

    If needed, $current could be re-established as current node using for-each:

    
        
        
                
                 becomes two
        
    
    

提交回复
热议问题