anchor.diff:  <%! 
       public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.addEditWebpageForm.jsp");
       
  -    public static String RANK_QUERY = 
  -        "PREFIX core: <http://vivoweb.org/ontology/core#> \n" + 
  -        "SELECT DISTINCT ?rank WHERE { \n" +
  -        "    ?subject core:webpage ?link . \n" +
  -        "    ?link core:rank ?rank .\n" +
  -        "} ORDER BY DESC(?rank) \n" +
  -        "LIMIT 1";
  -    
  +    /* Note on ordering by rank in sparql: if there is a non-integer value on a link, that will be returned. 
  +     * Preventing that would require getting all the ranks and ordering in Java, throwing out non-int values. 
  +     */
  +    public static String RANK_QUERY = ""
  +        + "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
  +        + "SELECT DISTINCT ?rank WHERE { \n"
  +        + "    ?subject core:webpage ?link . \n"
  +        + "    ?link core:rank ?rank .\n"
  +        + "} ORDER BY DESC(?rank) LIMIT 1";
  +
   %>
   
   <%
  
positive.code:          "literalOptions"   : [ ],
           "predicateUri"     : "",
           "objectClassUri"   : "",
           "rangeDatatypeUri" : "${stringDatatypeUriJson}",
           "rangeLang"        : "",
           "assertions"       : [ "${rankAssertion}" ]      
        }
  
negative.code:     
      String subjectName = ((Individual)request.getAttribute("subject")).getName();
      
      // Get largest existing rank value
      int maxRank = 0; // default value 
      if (objectUri == null) { // adding new webpage   
          String queryStr = QueryUtils.subUriForQueryVar(RANK_QUERY, "subject", subjectUri);
          log.debug("Query string is: " + queryStr);
          try {
              ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
              if (results != null && results.hasNext()) { // there is at most one result
                  QuerySolution soln = results.next(); 
                  RDFNode node = soln.get("rank");
                  if (node != null && node.isLiteral()) {
                      // node.asLiteral().getInt() won't return an xsd:string that 
                      // can be parsed as an int.
                      int rank = Integer.parseInt(node.asLiteral().getLexicalForm());
                      if (rank > maxRank) {  
                          log.debug("setting maxRank to " + rank);
                          maxRank = rank;
                      }
                  }
              }
          } catch (NumberFormatException e) {
              log.error("Invalid rank returned from query: not an integer value.");
          } catch (Exception e) {
              log.error(e, e);
          }
      }
  
  %>
  
  <c:choose>
  