Search code examples
xquerymarklogic

return boolean based on comparision


I have to return a boolean value based on comparision

fn:compare("12", "11")

If output is >1 then true if output is <=0 then false

Can anyone please help


Solution

  • Are you trying to compare the stringified numbers as numbers, or as strings?

    If you want to compare them as numbers, just do:

    fn:number("12") > fn:number("11")
    

    If you want to compare them as strings, do:

    fn:compare("12", "11") > 0
    

    HTH!