How can I remove whitespace when declaring an XSL variable?

前端 未结 4 987
你的背包
你的背包 2020-12-16 18:24

I have to create an XSL variable with a choose in it. Like the following:


  
    

        
4条回答
  •  再見小時候
    2020-12-16 18:51

    The strategies in the other answers are good, in fact preferable to this one when feasible. But there are times when you don't have control over (or it's harder to control) what's in the variable. In those cases, you can strip away the surrounding space when you're testing the variable:

    Instead of

    
    

    use

    
    

    normalize-space() strips the leading and trailing whitespace, and collapses other repeating white spaces to single ones.

提交回复
热议问题