XSLT to return boolean value if all tags are equal to value

前端 未结 3 972
礼貌的吻别
礼貌的吻别 2021-01-28 22:22

I have a xml:



    0
             


        
3条回答
  •  粉色の甜心
    2021-01-28 23:04

    I want to implement logic that will return true if one of the success tags is equal to 0 and false if all of them are equal to 0.

    First, let's make the truth table:

    All zeros | None zero | Some zero, others not
    -------------------------------------------
      False   |   False   |        True
    

    Second, node-set comparison in XPath are existencial. So:

    boolean(/soapenv:Envelope/soapenv:Body[success = 0 and success != 0])
    

    It will return true or false boolean value.

    This input

    
    
        0
        0
        1
    
    
    

    With this stylesheet

    
       
          
       
    
    

    Returns

    true
    

    Check it in http://www.utilities-online.info/xsltransformation/?save=ceed7a50-6a47-4c2c-b344-86ad3b3b0d92-xsltransformation

提交回复
热议问题