XSLT 1.0 Idiom for ternary if?

前端 未结 2 1786
醉梦人生
醉梦人生 2021-01-17 23:53

This Java program makes use of a Ternary if, to map booleans to output strings: (a \"*\" for true, an empty string for false).

public class ternary {
  publi         


        
2条回答
  •  无人共我
    2021-01-18 00:19

    You could utilise simple pattern matching in templates for this.

    
    
    
    

    So, the first one matches true entries, and the other one matches all other cases (which in your cases is just false

    So, given the following stylesheet

    
       
    
       
          *
       
    
       
          
       
    
       
          
       
    
    

    When applied to your sample XML, the following is output

    *
    
    *
    

提交回复
热议问题