XSLT: Replace single quotes by \'

后端 未结 5 541
梦毁少年i
梦毁少年i 2021-01-20 18:30

I am using XSLT to transform a XML into a html/php file. In this XSLT I replace some tags by php code and now I have to pass attribute values into that php code. My problem

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-20 19:13

    Use a recursive template to do the find/replace:

    
        
        
        
        
          
            
            
            
              
              
              
            
          
          
            
          
        
      
    

    Applied to your example:

       
        
            $this->doSomething('
            
                
                
                
            
            ');
        
    
    

    Note:

    1. The use of to explicitly define text intended for the output, and not have to worry about whitespace between that text and template calls.
    2. The use of single quotes to enclose the select statement for the replace and with parameters, in order to use double-quotes to indicate a text statement that contains a single quote
    3. The use of the entity reference ' for the single quote (a.k.a. apostrophe)

提交回复
热议问题