(xslt 1.0) How to replace the space with some string from all the text values in xml?

后端 未结 3 1963
北荒
北荒 2021-01-14 20:20

EDIT: [it started with character replacement and I ended up with discovering string replacements with help of Dimitre Novatchev and Rol

3条回答
  •  逝去的感伤
    2021-01-14 21:09

    Check out the XPath translate function: http://www.w3.org/TR/xpath/#function-translate

    
        
    
    

    If it's not a single character, but a string you have to replace, it takes considerably more effort, and you need a template to recursively replace the string:

    
        
            
            
            
        
    
    
    
        
        
        
        
            
                
                    
                        
                        
                        
                    
                
                
            
            
        
    
    

    Edit:changed match="text()" to match="text()[not(../*)]", so that the input xml need not be a kind of "pretty print XML" .. (so as to remove unwanted replacements of space with "%20" string in such xml file)

提交回复
热议问题