XSLT multiple string replacement with recursion

前端 未结 5 1558
花落未央
花落未央 2021-01-16 13:38

I have been attempting to perform multiple (different) string replacement with recursion and I have hit a roadblock. I have sucessfully gotten the first replacement to work

5条回答
  •  被撕碎了的回忆
    2021-01-16 14:29

    This stylesheet shows a verbose solution just for you to learn the pattern:

    
        
            
                
            
        
        
            
            
            
            
                
                    
                        
                    
                    

    With this input:

    THIS is a test.
    But THAT is not.
    THIS is also a test.
    

    Output:

    THAT is a test.
    But THAT is not.
    THAT is also a test.

    EDIT: Full parameterized solution.

    
        
            
    THAT

    Output:

    THAT is a test.
    But THAT is not.
    THAT is also a test.

    Note: There is a problem when using inline data in XML 1.0: you can't reset prefixed namespace declaration as in XML 1.1. The solution is to use a not common but valid notation: declare XSLT namespace as default namespace.

提交回复
热议问题