How can I remove whitespace when declaring an XSL variable?

前端 未结 4 983
你的背包
你的背包 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:48

    That's what is for:

    
      
        
          inside
        
        
          outside
        
      
    
    

    It allows you to structure your code and control whitespace at the same time.

    In fact, you should stay clear of text nodes in XSL that are not wrapped in to avoid these kinds of bugs in the future, too (i.e. when code gets re-formatted or re-factored later).

    For simple cases, like in your sample, doing what Jim Garrison suggests is also an option.


    As an aside, testing for the existence of an element with count() is superfluous. Selecting it is enough, since the empty node-set evaluates to false.

    
    

提交回复
热议问题