private Object maxOfList(Node lst, RuleContext context) { java.util.List<Node> l = Util.convertList(lst, context); Number max = null; XSDDateTime maxDate = null; for (int i = 0; l != null && i < l.size(); i++) { Node elt = (Node) l.get(i); if (elt != null && elt.isLiteral()) { Object v1 = elt.getLiteralValue(); if (v1 instanceof Number) { if (max == null || max.doubleValue() < ((Number) v1).doubleValue()) { max = (Number) v1; } } else if (v1 instanceof XSDDateTime) { if (maxDate == null || maxDate.compareTo((XSDDateTime) v1) < 0) { maxDate = (XSDDateTime) v1; } } else { throw new BuiltinException( this, context, "Element of list input to max not a number: " + v1.toString()); } } else { throw new BuiltinException( this, context, "Element of list input to max not a Literal: " + elt.toString()); } } if (maxDate != null) { return maxDate; } return max; }